Code RoomNim game winning position
MediumPrep Room Coding #841

Nim game winning position

CodingAlgorithms & data structuresMid–Senior~25 min

A pile has n stones. On each turn a player removes between 1 and m stones (inclusive). The player who takes the last stone WINS. Both play optimally and player one moves first. Return True if player one can force a win, else False. 0 <= n <= 10^9, 1 <= m <= 100. With n==0 there are no stones so player one cannot move and loses (return False).

Implement
bachet_first_wins(n: int, m: int) → bool
Examples
in[5,3]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[5,3]truenot run yetsample