Skip to content

Commit 69dee33

Browse files
authored
Create destroy-sequential-targets.py
1 parent ad42c2b commit 69dee33

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Python/destroy-sequential-targets.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(s), s is the value of space
3+
4+
import collections
5+
6+
7+
# freq table
8+
class Solution(object):
9+
def destroyTargets(self, nums, space):
10+
"""
11+
:type nums: List[int]
12+
:type space: int
13+
:rtype: int
14+
"""
15+
cnt = collections.Counter(x%space for x in nums)
16+
mx = max(cnt.itervalues())
17+
return min(x for x in nums if cnt[x%space] == mx)

0 commit comments

Comments
 (0)