Skip to content

Commit c6e8844

Browse files
committed
Time: 3 ms (51.08%), Space: 17.7 MB (66.29%) - LeetHub
1 parent 48137a9 commit c6e8844

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# time complexity: O(n)
2+
# space complexity: O(n)
3+
from typing import Counter, List
4+
5+
6+
class Solution:
7+
def getSneakyNumbers(self, nums: List[int]) -> List[int]:
8+
result = []
9+
for num, freq in Counter(nums).items():
10+
if freq == 2:
11+
result.append(num)
12+
return result
13+
14+
15+
nums = [7, 1, 5, 4, 3, 4, 6, 0, 9, 5, 8, 2]
16+
print(Solution().getSneakyNumbers(nums))

0 commit comments

Comments
 (0)