Problem · Sorting

Maximum System Memory Capacity

EasyAmazonINTERNNEW GRADOA
See Amazon hiring insights

The developers at Amazon are working on optimising the capacity of their cloud system. In the system, there are n servers where the memory capacity of the i-th server is represented by the array memory[i].

A system always contains an even number of servers. If the system has 2x servers, then x of them will be primary and the other x will be backup servers.

For each primary server P, there exists a backup server B where the memory capacity of B ≥ memory capacity of P. The system's memory capacity is the sum of the memory capacity of all the primary servers.

The problem statement continues
Pro
Examples
01 · Example 1
memory = [1, 2, 1, 2]
return = 3
Here, we have 4 servers [serverA, serverB, serverC, serverD] having memory sizes as [1, 2, 1, 2]. We can choose serverA and serverB as primary servers, and serverC and serverD as their respective backup. The conditions hold true since memory[serverC] ≥ memory[serverA] and memory[serverD] ≥ memory[serverB]. Hence, the maximum system memory capacity is 3.
2 original screenshots from the interview report
Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock the full problem

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock the full problem

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week