Skip to content

Commit 0476a6a

Browse files
committed
Runtime: 34 ms (Top 78.15%) | Memory: 16.60 MB (Top 64.13%)
1 parent b02bb9c commit 0476a6a

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
1+
// Runtime: 34 ms (Top 78.15%) | Memory: 16.60 MB (Top 64.13%)
2+
13
class Solution:
24
def divisorGame(self, n: int) -> bool:
3-
4-
"""
5-
let's forget about Alice and Bob for a second and just concentrate on the n and plays
6-
if played optimally :
7-
8-
1 - player at 1 will loose since no factors
9-
2 - player at 2 will win by choosing 1
10-
3 - player at 3 will loose always since he/she has to choose 1. and then next player will always win because they are at 2
11-
4 - player at 4 will win by choosing 1 as a factor as next player will have to play at 3
12-
5 - player at 5 will loose because he has to choose 1, and player at 4 will always win
13-
6 - player at 6 will always win by choosing 3 as a factor
14-
7 - player at 7 will have to choose 1, and hence result 6 will make player at 6 to win
15-
8 - player at 8 can choose 1 and win always
16-
.
17-
.
18-
.
19-
.
20-
Pattern detected
21-
22-
Now, since Alice is the first player we can return bool values accordingly
23-
24-
25-
"""
26-
275
return n%2 == 0
28-
29-

0 commit comments

Comments
 (0)