diff --git a/NeetCodeRoadmap/Arrays_and_Hashing/128_Longest_Consecutive_Sequence.py b/NeetCodeRoadmap/Arrays_and_Hashing/128_Longest_Consecutive_Sequence.py index 2299154..992e21c 100644 --- a/NeetCodeRoadmap/Arrays_and_Hashing/128_Longest_Consecutive_Sequence.py +++ b/NeetCodeRoadmap/Arrays_and_Hashing/128_Longest_Consecutive_Sequence.py @@ -10,9 +10,12 @@ def longestConsecutive(nums): for x in nums: if x < length and x not in sequence: sequence.append(x) + elif x == max(sequence)+1: + sequence.append(x) else: larger.append(x) return len(sequence) print(longestConsecutive([100,4,200,1,3,2])) -print(longestConsecutive([0,3,7,2,5,8,4,6,0,1])) \ No newline at end of file +print(longestConsecutive([0,3,7,2,5,8,4,6,0,1])) +print(longestConsecutive([1,3,5,2,4])) \ No newline at end of file