Compute duration and stopping rules correctly | Instacart Interview Question