Company: Amazon,HackerRank

Difficulty: medium

Problem Statement

In Amazon's web infrastructure, the system logs n API requests per second, recording each request's response time in the array responseTimes , where each element denotes the time taken to respond to a single request. To prevent system overload, a throttling mechanism is applied with the following behaviour: In each step, select the request with the minimum response time. This request is prioritised for further analysis. Remove the selected request and its immediate neighbours in the array (based on the original indices ) from the logs permanently. This process continues until all requests are removed. Your task is to calculate the total cumulative response time of all selected minimum requests over the entire throttling process. Note: If multiple requests have the same minimum response time, select the one with the lowest index. Input Format n responseTimes[0] responseTimes[1] ... responseTimes[n-1] The first line contains a single integer n , the number of integers in the array respon

More Amazon,HackerRank OA questionsInterview experiences