Back to questions

Longest Consecutive Sequence FAANG Python Interview Question

Longest Consecutive Sequence

FAANG Python Interview Question

Given an array of integers , return the length of the longest consecutive sequence of elements that can be formed from the array.

A consecutive sequence consists of elements where each element is exactly greater than the previous element. The elements in the sequence can be selected from any position in the array and do not need to appear in their original order.

Example #1

Input:

Output:

Explanation: The longest consecutive is which have a length of

Example #2

Input:

Output:

Explanation: The longest consecutive is which have a length of

Input

Python

Output