Skip to content

Commit 60d6bb1

Browse files
authored
Create count-pairs-that-form-a-complete-day-ii.py
1 parent 0dbca56 commit 60d6bb1

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: O(n + 24)
2+
# Space: O(24)
3+
4+
# freq table
5+
class Solution(object):
6+
def countCompleteDayPairs(self, hours):
7+
"""
8+
:type hours: List[int]
9+
:rtype: int
10+
"""
11+
result = 0
12+
cnt = [0]*24
13+
for x in hours:
14+
result += cnt[-x%24]
15+
cnt[x%24] += 1
16+
return result

0 commit comments

Comments
 (0)