This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Amazon Throttling Mechanism" covers key patterns like Arrays.
"n Amazon's web infrastructure, the system logs n API requests per second. Each request's response time is stored in an array responseTimes, where each element represents the time taken to respond to a single request. To prevent system overload, a throttling mechanism is applied with the following behavior: In each step, select the request with the minimum response time. If multiple requests have the same minimum response time, select the one with the lowest index. Remove the selected request and its immediate neighbors (based on original indices) permanently from the log. Repeat this process until all requests are removed. Your task is to calculate the total cumulative response time of all selected minimum requests throughout the throttling process. Example 1 Input: responseTimes = [4, 2, 9, 1, 7, 3] Process: Select 1, remove neighbors 9 and 7 Select 2, remove neighbor 4 Select 3, remove itself Selected values: 1 + 2 + 3 = 6 Output: 6"
Join thousands of developers practicing for Amazon.