1
# Runtime: 2982 ms (Top 22.53%) | Memory: 27.5 MB (Top 95.77%)
2
class Solution:
3
def stoneGameIX(self, stones: List[int]) -> bool:
4
u, d, t = 0, 0, 0
5
for stone in stones:
6
if stone % 3 == 1:
7
u += 1
8
elif stone % 3 == 2:
9
d += 1
10
else:
11
t += 1
12
if not u and d <= 2 or u <= 2 and not d: # situation 1 part 2
13
return False
14
if not u and d > 2 or u > 2 and not d: # situation 1 part 1
15
if not t % 2:
16
return False
17
else:
18
return True
19
if u == d or abs(u - d) <= 2: # situation 2 and situation 3
20
if t % 2:
21
return False
22
else:
23
return True
24
return True # default situation

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0