From 321c4d43bf694e61bb7ad4beb3b276af9f910668 Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Fri, 25 Aug 2023 21:45:55 -0700 Subject: [PATCH] clears 33/73 cases --- .../Arrays_and_Hashing/128_Longest_Consecutive_Sequence.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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