-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/longest-consecutive-sequence
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Test Case getting timedout in Leetcode ,
No Timeout solution at neetcode.io
MyCode
class Solution:
def longestConsecutive(self, nums: List[int]) -> int:
s = set(nums)
maxl = 0
for n in nums:
if n-1 in s:
continue
else:
curl = 1
while n + 1 in s:
curl += 1
n += 1
maxl = max(maxl,curl)
return maxl
TimedOut Test Case - https://docs.google.com/document/d/1UPJTlyvk76zMdOOa8FrK7jC8xX-sHn9mJ232sVv_X2Q/edit?usp=sharing
Metadata
Metadata
Assignees
Labels
No labels