Spaceship Equipment Loadout
Reported by candidates from Jane Street's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Jane Street reported this one in October 2026, and the constraint tells you the whole story: at most 18 equipment items. That's a hint to stop hunting for a clever DP and enumerate every subset. If you've got the OA coming up, this is a bitmask problem dressed up as a spaceship story. You pick a loadout under a weight cap, score it by how many of exactly five runs get fully covered, then break ties twice. The logic is easy. The tie-breaking is where people lose points. StealthCoder sits invisibly as a safety net if you blank mid-assessment.
The problem
Choose one fixed subset of spaceship equipment whose total weight does not exceed capacity. Equipment item i mitigates every hazard listed in protections[i]. A test run is fully mitigated when every hazard in that run is covered by at least one selected item. Exactly five runs are supplied. Maximize the number of fully mitigated runs. Break ties by smaller total equipment weight, then by the lexicographically smaller sorted list of selected equipment names. Return that sorted name list. Function optimizeLoadout(capacity: int, equipmentNames: String[], weights: int[], protections: String[][], runs: String[][]) → String[] Examples Example 1 capacity = 7 equipmentNames = ["Armor","Laser","Shield","Net"] weights = [4,3,4,2] protections = [["debris"],["pirates"],["asteroids"],["debris","pirates"]] runs = [["pirates"],["debris"],["asteroids"],["debris","pirates"],["pirates"]] return = ["Net","Shield"] Net and Shield weigh six and fully mitigate all five runs. Example 2 capacity = 3 equipmentNames = ["A","B","C"] weights = [2,2,3] protections = [["pirates"],["debris"],["pirates","debris"]] runs = [["pirates"],["debris"],["pirates","debris"],["asteroids"],["pirates"]] return = ["C"] C is the only feasible single item that fully mitigates both the combined run and the other covered runs. Constraints 1 <= equipmentNames.length <= 18. weights.length == protections.length == equipmentNames.length. Equipment names are unique; every weight is positive. runs.length == 5, and every run contains at least one hazard. Hazard names and equipment names are non-empty ASCII strings.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that 2^18 is only 262,144 subsets, and there are just five runs. Map each hazard string to a bit, then precompute a bitmask per item and a required mask per run. For each subset, compute total weight and the OR of protections. Skip it if weight exceeds capacity. A run counts as covered when (covered & runMask) == runMask. Count covered runs, then compare against the best: more runs wins, then lower weight, then the lexicographically smaller sorted name list. The pitfall is the final tie-break. Sort the selected names first, then compare lists element by element, not by bitmask order. Another trap is hazards in runs that no item protects. Those runs can never be covered, so don't crash on missing map keys. If the tie-break logic tangles on the live OA, StealthCoder is the hedge that hands you a clean implementation.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Spaceship Equipment Loadout 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Jane Street's OA.
Jane Street reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Spaceship Equipment Loadout FAQ
What's the trick to the Jane Street Spaceship Equipment Loadout problem?+
Brute force every subset with a bitmask. With at most 18 items you only check 262,144 combinations. Encode hazards as bits, OR together item protections, and check each of the five runs against its required mask. No fancy optimization needed.
How hard is this problem really?+
Medium on difficulty, but it's easy to lose points on details. The enumeration is standard. The hard part is the three-level comparison: most runs covered, then lower weight, then lexicographically smaller sorted names. Get that comparator right and you're done.
How do I handle the lexicographic tie-break?+
Build the sorted list of selected names for any candidate that ties on both run count and weight. Compare it to the current best list element by element. Only build the lists when you actually tie, which keeps the loop fast and the code simple.
What if a run has a hazard no equipment protects?+
That run can never be fully mitigated, so it just never counts. Build your hazard-to-bit map from all hazards across both protections and runs, so lookups don't fail. Then the mask check naturally fails for that run.
How do I prepare for this in 48 hours?+
Practice bitmask subset enumeration and writing a multi-key comparator. Do one pass of this problem from scratch with the two examples. Check that an empty subset is handled, since it's valid if nothing fits. Make sure you can code the hazard-to-bit mapping without thinking.