Given an unsorted array of integers, return the length of the longest run of consecutive integers that can be formed using the numbers in the array. Your algorithm should run in O(n) time.
nums = [100,4,200,1,3,2]4nums = [0,3,7,2,5,8,4,6,0,1]9Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Arrays give O(1) index access; hash maps and sets give O(1) average lookup, insert, and delete by trading space for speed. Together they're the toolkit for turning brute-force O(n²) comparisons into a single O(n) pass.
Read the full Arrays & Hashing guide →
Original problem on LeetCode ↗