Skip to content

Commit faa1137

Browse files
authored
Update subtree-removal-game-with-fibonacci-tree.cpp
1 parent 8089c85 commit faa1137

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

C++/subtree-removal-game-with-fibonacci-tree.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
class Solution {
55
public:
66
bool findGameWinner(int n) {
7-
return n % 6 != 1; // the cycle period is 6 observed from solution2, which could be proved by mathematical induction
7+
// every 6 grundy numbers in binary:
8+
// 0000, (XXXX+1)01, (XXXX+1)11, (((XXXX+1))^((XXXX+1)+1))10, (XXXX+1)11, (XXXX+1)11
9+
return n % 6 != 1;
810
}
911
};
1012

0 commit comments

Comments
 (0)