FastPrepMinimum Servers for an Exact Load
Problems/Minimum Servers for an Exact Load

Minimum Servers for an Exact Load

JP Morgan Chase logoJP Morgan Chase● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern online assessment. Our task is about 100% the same as the photographed report. A separate internship report names Server Selection but gives no capacity rule, target, or goal. Linking it here is our own reading. The power-of-two capacities, exact load, no server reuse, and minimum count come from the photographed task, not from that report with only a name.

You are given an array server of request-handling capacities and an integer expected_load. Every capacity is a power of two.

Choose the minimum number of servers whose capacities sum to exactly expected_load.

  • Each server may be selected at most once.
  • Different servers may have the same capacity.
  • The selected capacities must equal the load exactly; exceeding it is not allowed.

Return the minimum number of selected servers, or -1 if no selection is possible.

Function

getMinServers(expected_load: int, server: int[]) → int

Examples

Example 1

expected_load = 3server = [1,1,2,4]return = 2

Select the server of capacity 2 and either server of capacity 1. Their total capacity is 1 + 2 = 3. No single server has capacity 3, so two servers are necessary and sufficient.

Example 2

expected_load = 4server = [1,1,1]return = -1

All three servers together provide capacity 3, which is less than 4. No selection can meet the load.

Constraints

  • 1 <= server.length <= 10^5
  • 1 <= server[i] <= 10^9
  • Every capacity is a power of two.
  • 1 <= expected_load <= 10^9

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Invert Ad Visibility BitsOA · Seen Aug 2026

Similar questions at other companies

  • Minimize the Maximum Array ElementChubb · OAChubb interview questions
  • Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
  • Server SelectionPoint72 · OAPoint72 interview questions
  • Get Max Or SumMicrosoft · OAMicrosoft interview questions
  • Maximize PartitionsAmazon · OA
  • Fewest Steps to Build an Array from ZerosExpedia · OAExpedia interview questions
  • Maximum XOR Elimination ScoreRippling · OARippling interview questions
  • Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
  • Minimum Row Deletions to Prevent a Target ORInMobi · ONSITE INTERVIEWInMobi interview questions
  • Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon · OA

Interview reports that mention this question

  • JPMorgan Code for Good India: 10 Experiences (Part 4 of 5)
  • JPMorgan Tech Intern HackerRank OA: 11 Experiences (Part 3 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int getMinServers(int expected_load, int[] server) {
        // Write your code here.
    }
}
Checking account…