Algorithm · DoorDash · Medium
You are given a single day's log of order-status events for one Dasher, and you must compute how much the Dasher earns in total. Each order counts as active from the moment of its START event until its corresponding END event. At every moment, earnings accrue at a rate of $$R \times (\text{number of active orders})$$, where $$R$$ is the base rate. On top of this, certain peak-time windows double the rate: Outside peak time the rate is $$R \times (\text{active orders})$$.…