Search⌘ K
AI Features

Longest Consecutive Sequence

Understand how to identify and return the length of the longest consecutive sequence in an unsorted array by applying the union-find algorithm. This lesson helps you develop problem-solving skills for graph and connectivity issues relevant to coding interviews.

Statement

Given an unsorted array, nums, your task is to return the length of the longest consecutive sequence of elements. The consecutive sequence of elements is such that there are no missing elements in the sequence. The consecutive elements can be present anywhere in the input array.

Note: Two elements, xx and yy ...