Feature #5: Order Processing Milestones

Implementing the "Order Processing Milestones" feature for our "Amazon" project.


Let’s assume the Amazon team wants to collect stats of the number of orders processed. These stats will be presented in a quarterly report using a histogram. To collect data for this presentation, the devs have stored the number of orders for each day rounded down to the nearest significant milestone. For example, when we meet or exceed one million orders, we display “1M+ orders processed.” We continue to display the same message until another milestone is reached. For instance, when nine million orders or more are processed, we display “9M+ orders processed.” Every day, the rounded cumulative number of orders processed is appended to an array.

Now, our task is to find out how many days we spent jumping from one milestone to the next. We will be given the array containing the daily milestones. Assume that this array resets each quarter, so we start from 0 million. Let’s say the array is: [0, 1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5, 6, 7]. This array shows the stats for fourteen days. Now, we will also be given a value representing a certain milestone; suppose it is 4. This means that we need to find in which days the “4M+ orders processed” milestone occurred.

Our feature should return [7, 9], which means that we remained at the 4M+ milestone from the 7th day to the 9th day. (The first day of the quarter is considered the 0th day. )

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.