forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_1025.java
More file actions
15 lines (14 loc) · 670 Bytes
/
_1025.java
File metadata and controls
15 lines (14 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.fishercoder.solutions;
public class _1025 {
public static class Solution1 {
/**
* After writing out a few examples, beginning from n = 1, up to n = 5, the logic flows out naturally:
* 1. when N deduced to 1, whoever plays now loses because no integers exist between 0 and 1;
* 2. when N deduced to 2, whoever plays now wins because he/she will pick one and the next player is left with nothing to play;
* 3. all numbers N will eventually be deduced to either 1 or 2 depending on whether its odd or even.
*/
public boolean divisorGame(int N) {
return N % 2 == 0;
}
}
}