Problem · Sorting
Channels Max Quality
Learn this problemProblem statement
You are given a list of packets of varying sizes and there are n channels.
n channel must have a single packet
The quality of a channel is described as the median of the packet sizes on that channel. The total quality
is defined as sum of the quality of all channels (round to integer in case of float).
Given the packet sizes and num of channels, find the maximum quality.
Function
calculateMedianSum(packets: int[], n: int) → int
Complete the function calculateMedianSum in the editor.
calculateMedianSum has the following parameters:
int[] packets: an array of integersint n: the number of channels
Returns
int: the sum of the medians of each channel
Examples
Example 1
packets = [1, 2, 3, 4, 5]n = 2return = 8If packet {1, 2, 3, 4} is sent to channel 1, the median of that channel would be 2.5
If packet {5} is sent to channel 2, its median would be 5
Max total quality is 2.5 + 5 = 7.5 ~ 8
Example 2
packets = [5, 2, 2, 1, 5, 3]n = 2return = 7channel 1 -> {2, 2, 1, 3,}, median = 2
channel 2 -> {5, 5}, median = 5
total quality 2 + 5 = 7
Constraints
Unknown for nowMore Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026