FastPrepMinimum First Bucket in Modified Nim
Problems/Minimum First Bucket in Modified Nim

Minimum First Bucket in Modified Nim

Adobe logoAdobe● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Adobe online assessment for full-time roles. The report gives the pattern of adding and removing items, switching each move, for the first 50 moves. It asks for the smallest first bucket that wins. The numeric limits in the report are missing. In our version, each player move counts on its own. The original heaps are positive and go up to 10^9. We assume both players play perfectly. Our version is about 96% the same as the reported question.

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:

  1. Shashank adds a new bucket containing a positive number of balls.
  2. Sara adds a new bucket containing a positive number of balls.
  3. Shashank makes one removal.
  4. 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[]) → int

Examples

Example 1

heaps = [10]return = 10

The 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 = -1

The 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)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int minimumFirstBucket(int[] heaps) {
        // Write your solution here.
    }

}
Checking account…