Skip to content

Commit b011c74

Browse files
Added solution
1 parent 1b965de commit b011c74

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

longest_common_sequence.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def longestConsecutive(self, nums: List[int]) -> int:
3+
nums = set(nums)
4+
best = 0
5+
for x in nums:
6+
if x - 1 not in nums:
7+
y = x + 1
8+
while y in nums:
9+
y += 1
10+
best = max(best, y - x)
11+
return best

0 commit comments

Comments
 (0)