Leetcode 292 Solution

This article provides solution to leetcode question 292 (nim-game)

https://leetcode.com/problems/nim-game

Solution

class Solution {
public:
    bool canWinNim(int n) {
        switch ((n - 1) % 4)
        {
            case 0:
            case 1:
            case 2:
                return true;
            case 3:
                return false;
        }

        return false;
    }
};