Skip to content

Commit defe939

Browse files
committed
Runtime: 574 ms (Top 89.21%) | Memory: 15.3 MB (Top 66.59%)
1 parent e2894ec commit defe939

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
# Runtime: 574 ms (Top 89.21%) | Memory: 15.3 MB (Top 66.59%)
12

23
import collections
34
class Solution:
45
def isPossible(self, nums: List[int]) -> bool:
5-
6+
67
counter = collections.Counter(nums)
78
end = collections.defaultdict(int)
89

910
for num in nums:
10-
11+
1112
if counter[num]:
1213
counter[num]-=1
13-
14+
1415
if end[num-1]:
1516
end[num-1]-=1
1617
end[num]+=1
@@ -20,4 +21,4 @@ def isPossible(self, nums: List[int]) -> bool:
2021
end[num+2] +=1
2122
else:
2223
return False
23-
return True
24+
return True

0 commit comments

Comments
 (0)