Longest Consecutive Sequence: O(n²) → O(n) in 10 Minutes

This video explains Longest Consecutive Sequence by first building an O(n²) solution, then improving it to O(n) with a hash set. The key optimization is recognizing that we should only begin counting a sequence when the previous number does not exist. From there, we count forward and track the longest sequence. I’m working through the NeetCode 150 as an average CS student and explaining how each solution improves step by step instead of only showing the final code. Problem: Longest Consecutive Sequence LeetCode: 128 Pattern: Arrays & Hashing Complexities covered: O(n²) and O(n) Watch the full NeetCode 150 From Scratch playlist on my channel. #leetcode #neetcode150 #codinginterview