Skip to content

Commit 7145380

Browse files
refactor 292
1 parent e1d872f commit 7145380

File tree

1 file changed

+10
-7
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+10
-7
lines changed

src/main/java/com/fishercoder/solutions/_292.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313

1414
public class _292 {
1515

16-
/**1. If there are only 1 or 2 or 3 stones, you could always win by taking 1 or 2 or 3 stones;
17-
* 2. If there are 4 stones, you could never win because no matter you tak 1 or 2 or 3 stones, you could never take the 4th one;
18-
* 3. If there are 5 or 6 or 7 stones, you could always win because no matter how your opponent works, you'll always get the last one;
19-
* 4. Then we could deduce that as long as the number is not divisible by 4, you could always win.*/
16+
public static class Solution1 {
17+
/**
18+
* 1. If there are only 1 or 2 or 3 stones, you could always win by taking 1 or 2 or 3 stones;
19+
* 2. If there are 4 stones, you could never win because no matter you tak 1 or 2 or 3 stones, you could never take the 4th one;
20+
* 3. If there are 5 or 6 or 7 stones, you could always win because no matter how your opponent works, you'll always get the last one;
21+
* 4. Then we could deduce that as long as the number is not divisible by 4, you could always win.
22+
*/
2023

21-
public boolean canWinNim(int n) {
22-
return n % 4 != 0;
24+
public boolean canWinNim(int n) {
25+
return n % 4 != 0;
26+
}
2327
}
24-
2528
}

0 commit comments

Comments
 (0)