Decide the Winner of One-to-Three Stone Nim

Quick Overview

Decide the Winner of One-to-Three Stone Nim. Two optimal players alternately remove one, two or three stones from a single heap. You move first; taking the final stone wins. Return whether you can force a

Decide the Winner of One-to-Three Stone Nim

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Two optimal players alternately remove one, two or three stones from a single heap. You move first; taking the final stone wins. Return whether you can force a win from n stones. ```cpp bool canWinNim(int n); ``` ### Examples ```text n = 8 -> false n = 10 -> true ``` ### Constraints - 1 <= n <= 2147483647.

Overview: Decide the Winner of One-to-Three Stone Nim. Two optimal players alternately remove one, two or three stones from a single heap. You move first; taking the final stone wins. Return whether you can force a

Meta logo
Meta
Date not reported
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Two optimal players alternately remove one, two or three stones from a single heap. You move first; taking the final stone wins. Return whether you can force a win from n stones.

bool canWinNim(int n);

Examples

n = 8 -> false
n = 10 -> true

Constraints

  • 1 <= n <= 2147483647.