Search⌘ K

Feature #5: Order Processing Milestones

Explore how to identify the duration spent at specific order processing milestones using a modified binary search algorithm in Rust. This lesson helps you understand milestone tracking for quarterly reports and develop efficient searching techniques applicable to real-world coding interview problems at Amazon.

Description

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, your task is to find out how many days we spent jumping from one milestone to the next. You 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, you will also be given a value representing a certain milestone; suppose it is 4. This means that you need to find in which days the “4M+ orders processed” milestone occurred.

Your feature should return [7, 9], which ...