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 4444560 commit e10c1c9Copy full SHA for e10c1c9
Longest Consecutive Sequence - Leetcode 128.py
@@ -3,7 +3,7 @@ def longestConsecutive(self, nums: List[int]) -> int:
3
s = set(nums)
4
longest = 0
5
6
- for num in nums:
+ for num in s: # Fixed to loop through the set, this is important
7
if num - 1 not in s:
8
next_num = num + 1
9
length = 1
0 commit comments