Skip to content

Bug Report for longest-consecutive-sequence #4960

@MrutunjayTiwari

Description

@MrutunjayTiwari

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions