Company: JPMorgan Chase - Code For Good - India Campus Hiring - 2026 Batch SI_24march
Difficulty: medium
You are given n servers, where each server has a request-handling capacity listed in the array server . Each capacity is guaranteed to be a power of 2 (such as 1, 2, 4, 8, ...). You are also given an integer expected_load . Your task is to determine the minimum number of servers whose capacities add up to exactly expected_load . Notes: Each server can be selected at most once The total capacity of selected servers must be exactly equal to expected_load If no such selection is possible, return -1 Example 1 Suppose n = 4, servers = [1, 1, 2, 4], and expected_load = 3. Output: 2 Explanation: It is optimal to choose the first and the third or the second and the third servers serving a total of 1 + 2 = expected_load = 3 requests. Example 2 Suppose n = 3, servers = [1, 1, 1], and expected_load = 4. Output: -1 Explanation: There is no server selection that can handle 4 requests. Constraints: 1 ≤ n ≤ 10 5 1 ≤ server[i] ≤ 10 9 It is guaranteed that server[i] is a power of 2. 1 ≤