Skip to content

Commit 527c180

Browse files
committed
commit
1 parent 8bd9a6e commit 527c180

File tree

17 files changed

+601
-221
lines changed

17 files changed

+601
-221
lines changed

.idea/modules.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 274 additions & 221 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

[0207][Course Schedule]/[0207][Course Schedule].iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
<SOURCES />
1818
</library>
1919
</orderEntry>
20+
<orderEntry type="library" name="R User Library" level="project" />
21+
<orderEntry type="library" name="R Skeletons" level="application" />
2022
</component>
2123
</module>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @author: wangjunchao(王俊超)
3+
* @time: 2019-07-08 20:52
4+
**/
5+
public class Solution {
6+
7+
}

[0240][Search a 2D Matrix II]/[0240][Search a 2D Matrix II].iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
<SOURCES />
1818
</library>
1919
</orderEntry>
20+
<orderEntry type="library" name="R User Library" level="project" />
21+
<orderEntry type="library" name="R Skeletons" level="application" />
2022
</component>
2123
</module>

[0241][Different Ways to Add Parentheses]/[0241][Different Ways to Add Parentheses].iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
<SOURCES />
1818
</library>
1919
</orderEntry>
20+
<orderEntry type="library" name="R User Library" level="project" />
21+
<orderEntry type="library" name="R Skeletons" level="application" />
2022
</component>
2123
</module>

[0292][Nim Game]/[0292][Nim Game].iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

[0292][Nim Game]/src/Solution.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* https://leetcode.com/problems/nim-game/
3+
* @author: wangjunchao(王俊超)
4+
* @time: 2019-07-08 18:39
5+
**/
6+
public class Solution {
7+
/**
8+
* <pre>
9+
* You are playing the following Nim Game with your friend: There is a heap of stones on the table,
10+
* each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will
11+
* be the winner. You will take the first turn to remove the stones.
12+
*
13+
* Both of you are very clever and have optimal strategies for the game. Write a function to determine
14+
* whether you can win the game given the number of stones in the heap.
15+
*
16+
* Example:
17+
*
18+
* Input: 4
19+
* Output: false
20+
* Explanation: If there are 4 stones in the heap, then you will never win the game;
21+
* No matter 1, 2, or 3 stones you remove, the last stone will always be
22+
* removed by your friend.
23+
*
24+
* 这题往小说可以追溯到小学奥数或者脑筋急转弯的书中,往大说可以深究到博弈论。然而编程在这里并没有卵用,
25+
* 策略在于,因为每个人都取不到4个,假设自己后走,要保证每轮自己和对方取得数量的和是4,这样就能确保每
26+
* 轮完后都有4的倍数个石头被取走。这样,如果我们先走的话,先把n除4的余数个石头拿走,这样不管怎样,到最
27+
* 后都会留4个下来,对方取1个你就取3个,对方取2个你就取2个,就必赢了。
28+
* </pre>
29+
* @param n
30+
* @return
31+
*/
32+
public boolean canWinNim(int n) {
33+
return (n & 0b11) > 0;
34+
}
35+
36+
public boolean canWinNim2(int n) {
37+
return n %4 != 0;
38+
}
39+
}

[0427][Construct Quad Tree]/[0427][Construct Quad Tree].iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
<SOURCES />
1818
</library>
1919
</orderEntry>
20+
<orderEntry type="library" name="R User Library" level="project" />
21+
<orderEntry type="library" name="R Skeletons" level="application" />
2022
</component>
2123
</module>

0 commit comments

Comments
 (0)