Amazon Coding Question – Solved

9 Live
After all the servers are down, the developers must send one more request to conclude the failure of the application. The developers at Amazon want to perform a reliability drill on some servers. There are n servers where the i-th server can serve request[i] number of requests and has an initial health of health[i] units. Each second, the developers send the maximum possible number of requests that can be served by all the available servers. With the request, the developers can also send a virus to one of the servers that can decrease the health of a particular server by k units. The developers can choose the server where the virus should be sent. A server goes down when its health is less than or equal to 0. Find the minimum total number of requests that the developers must use to bring all the servers down. Example Consider n = 2, request = [3, 4], health = [4, 6], k = 3. The minimum number of requests required is 21. | No. of Requests | Virus Server | Server’s New Health | Total Requests | |----------------|--------------|----------------------|----------------| | 3 + 4 = 7 | 1 | 6 - 3 = 3 | 7 | | 3 + 4 = 7 | 1 | 3 - 3 = 0 (server 1 dies) | 14 | | 3 | 0 | 4 - 3 = 1 | 17 | | 1 | 0 | 1 - 3 = -2 (server 0 dies) | 18 | | - | - | - (conclude the failure) | 21 |

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| You are given a board of size M Γ— N where each cell can be either empty ('O') o… |
| Undirected Coloured Graph Shortest Path You are given an undirected weight… |
| Village Voyage A computer game "Village Voyage" has N villages (labeled 1 to… |
| Academic Decathlon Students are being selected for an academic decathlon tea… |
| Sum of Arrays Given two arrays each of length n, arr1 and arr2, in one opera… |
| Count Swaps During Custom Sorting Analyze the efficiency of the following so… |