Company: Amazon_14oct
Difficulty: medium
Code Question 1 Problem Description 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 ith 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. Given n servers and an array memory, find the maximum system memory capacity that can be formed using the n servers. Examples Consider the following conceptual examples for selecting primary and backup servers: Primary Servers Options Backup Servers Options Conditions Valid Option serverA, serverB serverC, serverD memory[serverA] ≤ memory[serverC] memory[serverB] ≤ memory[serverD] No serverA, serve