We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f99b92 commit 8c2adbcCopy full SHA for 8c2adbc
1 file changed
longest-consecutive-sequence/hyeri0903.py
@@ -0,0 +1,17 @@
1
+class Solution:
2
+ def longestConsecutive(self, nums: List[int]) -> int:
3
+ if len(nums) <= 0:
4
+ return 0
5
+ res , cnt = 1, 1
6
+ sorted_nums = list(set(nums))
7
+ sorted_nums.sort()
8
+ print(sorted_nums)
9
+
10
+ for i in range(len(sorted_nums)-1):
11
+ if sorted_nums[i+1] - sorted_nums[i] == 1:
12
+ cnt += 1
13
+ else:
14
+ cnt = 1
15
+ res = max(res, cnt)
16
+ return res
17
0 commit comments