Leetcode 128 - Longest Consecutive Sequence JavaScript

Опубликовано: 06 Май 2026
на канале: Chuck's Resume
189
1

Leetcode 128 asks, "Given an unsorted array of integers, find the length of the longest consecutive elements sequence." In this video I show you three different solutions. The first two perform the algorithm in O(n) linear time. The third solution is a little bit slower, but solves the challenge not using sorting, which makes the problem a little trickier. Definitely worth understanding all three!

Leetcode 128: https://leetcode.com/problems/longest...

Leetcode 128 Source Code: https://github.com/Brixsta/Algorithms...

Chapters:
0:00 Intro
1:11 Solution using Set and Sort
6:21 Solution without using Set
7:53 Solution without using Set or Sort
12:25 Outro