Amazon Coding Question – Solved

4 Live
GetMaxThroughput The developers at Amazon are working on optimizing database query times. There are n host servers, where the throughput of the i-th host server is given by host_throughput[i]. These servers are grouped into clusters of size three. The throughput of a cluster, denoted as cluster_throughput, is defined as the median of the three servers’ throughput values. Each host server can be part of at most one cluster, and some servers may remain unused. The total system throughput, called system_throughput, is the sum of the throughputs of all the clusters formed. The task is to find the maximum possible system throughput. Note: The median of a cluster of three host servers is the 2nd highest throughput when the three values are sorted in ascending or descending order. Example: Input: n = 5 host_throughput = [2, 3, 4, 3, 4] Output: The maximum number of clusters that can be formed is 1, and two host servers will remain unused.

Asked in: Amazon

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |