Skip to content

Commit 8dd7af8

Browse files
committed
Add solution for leetcode longestConsecutive
1 parent 75c9a4a commit 8dd7af8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def longestConsecutive(nums):
2+
longest = 0
3+
4+
for num in nums:
5+
length = 1
6+
while num + length in nums:
7+
length += 1
8+
longest = max(longest, length)
9+
10+
return longest

0 commit comments

Comments
 (0)