Skip to content

Commit 990485c

Browse files
committed
Create 2682.find-the-losers-of-the-circular-game.py
1 parent e3d6198 commit 990485c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://leetcode.cn/problems/find-the-losers-of-the-circular-game/
2+
3+
4+
class Solution1:
5+
'''
6+
Date: 2023.08.16
7+
Pass/Error/Bug: 1/0/0
8+
执行用时: 52 ms, 在所有 Python3 提交中击败了 51.94% 的用户
9+
内存消耗:15.77 Mb, 在所有 Python3 提交中击败了 14.60% 的用户
10+
'''
11+
def circularGameLosers(self, n: int, k: int) -> List[int]:
12+
count_dict = {}
13+
i = 0
14+
for idx in range(n):
15+
i = (i + idx*k) % n
16+
if i in count_dict:
17+
break
18+
else:
19+
count_dict[i] = 1
20+
21+
return [ i+1 for i in range(n) if i not in count_dict ]

0 commit comments

Comments
 (0)