Minimum Racks for Server Resources
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Google's August 2026 OA includes Minimum Racks for Server Resources, and the constraint that matters is n <= 15. That tiny number is the whole hint. It's a two-dimensional bin packing problem, and greedy sorting will burn you because it looks right and fails on edge cases. The answer is a bitmask DP over subsets. If you've got an invite and 15 sounds suspiciously small, trust it. StealthCoder is there as a safety net on the live OA if the mask transitions slip your mind, but the pattern is learnable tonight.
The problem
You are given n indivisible servers. Server i requires bandwidth[i] units of bandwidth and power[i] units of power. Every rack has a bandwidth capacity of rackBandwidthCapacity and a power capacity of rackPowerCapacity. A group of servers can share one rack only when both of these conditions hold: The sum of their bandwidth requirements is at most rackBandwidthCapacity. The sum of their power requirements is at most rackPowerCapacity. Assign every server to exactly one rack and return the minimum number of racks required. Function minimumRacks(bandwidth: int[], power: int[], rackBandwidthCapacity: int, rackPowerCapacity: int) → int Examples Example 1 bandwidth = [4,4,2] power = [3,2,3] rackBandwidthCapacity = 6 rackPowerCapacity = 5 return = 2 The server with requirements (4, 2) can share a rack with the server requiring (2, 3). Their totals are (6, 5). The remaining server uses a second rack. Example 2 bandwidth = [3,3,3,3] power = [4,4,4,4] rackBandwidthCapacity = 6 rackPowerCapacity = 8 return = 2 Each rack can hold exactly two servers, so two racks are sufficient and necessary. Example 3 bandwidth = [2,2,2] power = [6,6,6] rackBandwidthCapacity = 10 rackPowerCapacity = 10 return = 3 Bandwidth would allow the servers to share, but any pair needs 12 power units. Each server therefore needs its own rack. Constraints 1 <= bandwidth.length == power.length <= 15. 1 <= bandwidth[i] <= rackBandwidthCapacity <= 10^6. 1 <= power[i] <= rackPowerCapacity <= 10^6. Every server fits in an otherwise empty rack.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick: with n <= 15 you can enumerate all 2^15 subsets. First precompute, for every mask, the total bandwidth and total power, then mark the mask valid if both fit the rack capacities. Then dp[mask] is the minimum racks to hold exactly those servers. Transition by iterating submasks of mask that are valid: dp[mask] = min(dp[mask ^ sub] + 1). Total work is about 3^15, roughly 14 million, which is fine. The common pitfall is greedy first-fit-decreasing, which fails in two dimensions because there's no single sort order. Another pitfall is forgetting both constraints must hold together, as Example 3 shows. Fix the lowest set bit in each submask to cut duplicate work. If you blank on submask enumeration during the live OA, StealthCoder can surface the loop (sub = (sub - 1) & mask) while you stay on task.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Minimum Racks for Server Resources cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Racks for Server Resources FAQ
What's the trick in Minimum Racks for Server Resources?+
Bitmask DP. With n at most 15, precompute which subsets fit in one rack (both bandwidth and power sums within capacity), then dp[mask] is the fewest racks for that set. Transition over valid submasks. Greedy fails because two dimensions have no consistent sort order.
Why doesn't greedy sorting work here?+
Sorting by bandwidth can pair servers that waste power, and sorting by power does the reverse. Two constraints mean no single ordering is safe. Example 3 shows bandwidth alone would allow sharing while power forbids it. The small n is a signal to go exact.
What's the time complexity and will it pass?+
Iterating all submasks of all masks is 3^n, about 14.3 million operations for n = 15. That passes comfortably. Precomputing subset sums is 2^n times n at worst, or 2^n with the lowest-bit trick. Memory is just a couple of arrays of 32768 entries.
How do I implement submask enumeration correctly?+
For each mask, loop sub = mask; sub > 0; sub = (sub - 1) & mask. Skip subsets that aren't valid single-rack groups. Set dp[0] = 0 and everything else to infinity. dp[mask] = min(dp[mask ^ sub] + 1). The answer is dp[(1<<n) - 1].
How do I prepare for this in 48 hours?+
Write the bitmask DP from scratch once. Do a subset-sum precompute, then the submask loop. Test against the three examples, especially the one where power blocks sharing. Also review similar problems like partitioning into groups with a capacity limit, since the same skeleton shows up often.