Amazon Coding Question – Solved

5 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

| 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… |