Minimum First Bucket in Modified Nim
Updated
Problem statement
Shashank and Sara play a game with the nonempty buckets in heaps. Shashank moves first. A removal takes a positive number of balls from one bucket and may empty it. The player who takes the last ball wins.
During the first 50 individual player moves, repeat this four-move pattern:
- Shashank adds a new bucket containing a positive number of balls.
- Sara adds a new bucket containing a positive number of balls.
- Shashank makes one removal.
- Sara makes one removal.
After move 50, both players only make removals, following ordinary Nim. Each player chooses moves optimally. Return the smallest positive number of balls that Shashank can put in his first added bucket to force a win. Return -1 if no such choice exists. Added bucket sizes are not capped by the bounds on the original heaps.
Function
minimumFirstBucket(heaps: int[]) → intExamples
Example 1
heaps = [10]return = 10The original XOR is 10. Adding another bucket of size 10 leaves XOR zero. Shashank can keep leaving XOR zero on each of his moves, so Sara cannot take the last ball and the later ordinary Nim phase favors Shashank.
Example 2
heaps = [1,2,3]return = -1The original XOR is 1 xor 2 xor 3 = 0. A zero-sized addition is forbidden. Every positive first addition lets Sara take over the strategy of leaving XOR zero, so no first bucket forces a win.
Constraints
- For this exercise, assume 1 <= heaps.length <= 100000.
- For this exercise, assume 1 <= heaps[i] <= 1000000000.
Source note: Original OA task images and any included source example. The practice contract follows the rules stated in the problem and source note.
More Adobe Online Assessment questions
- Base Unit ConversionsOA · Seen Nov 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Count Parent Nodes With a Target SumOA · Seen Aug 2026
- Largest Binary Number by ConcatenationOA · Seen Aug 2026
- Count Events by CategoryOA · Seen Aug 2026
- Graph M-ColoringOA · Seen Aug 2026
- Hall of Shifting TilesOA · Seen Aug 2026
- K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
- Maze ReachabilityOA · Seen Aug 2026
Similar questions at other companies
- Match an XOR-Adjusted SumSquarepoint Capital · OASquarepoint Capital interview questions
- XOR ColoringMicrosoft · OAMicrosoft interview questions
- Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
- Address on Same PageNVIDIA · OANVIDIA interview questions
- Minimum Power-of-Two Removal OperationsIBM · OAIBM interview questions
- Minimum Power-of-Two Removal OperationsVisa · OAVisa interview questions
- Find the Missing Number from 1 to nGEP · OA
- Invert Ad Visibility BitsJP Morgan Chase · OAJP Morgan Chase interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)