-
Notifications
You must be signed in to change notification settings - Fork 3
/
q1560.py
33 lines (32 loc) · 961 Bytes
/
q1560.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
from typing import List
class Solution:
def mostVisited(self, n: int, rounds: List[int]) -> List[int]:
times = [0 for _ in range(n)]
times[rounds[0] - 1] = 1
last = rounds[0]
for number in rounds:
if number == last:
continue
elif number > last:
for i in range(last,number):
times[i % n] += 1
last = number
else:
for i in range(last, number + n):
times[i % n] += 1
last = number
print(times)
maxVal = times[0]
for time in times:
if time > maxVal:
maxVal = time
result = list()
for i in range(len(times)):
if times[i] == maxVal:
result.append(i + 1)
return result
n = 7
rounds = [7,1,7]
result = Solution().mostVisited(n, rounds)
print(result)