---
# System prepended metadata

title: Untitled

---

Given an array of integers, return the length of the longest consecutive elements sequence.

> Example 1:
> Input = [100, 4, 200, 1, 3, 2]
> Output: 4
> Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.

> Example 2:
> Input = [3, 0, 7, 2, 5, 8, 4, 6, 0, 1] 
> Output: 9
> Explanation: The longest consecutive elements sequence is [0, 1, 2, 3, 4, 5, 6, 7, 8]. Therefore its length is 9

> Example 3:
> Input = [7, 5, -5, -4, -3, 0, 2, 4, 6]
> Output: 4
> Explanation: The longest consecutive elements sequence is [4, 5, 6, 7]. Therefore its length is 4

> Example 4:
> Input = [1, 88, 91, 3, 90, 2, 89]
> Output: 4
> Explanation: This example contains two different consecutive elements sequences: [1, 2, 3] and [88, 89, 90, 91]. The longest of these sequences contains 4 elements, therefore the output should be 4.

> Example 5:
> Input = [2, 3, 1, 3, 2, 3, 1]
> Output = 3
> Explanation: The longest consecutive elements sequence is [1, 2, 3]. Therefore its length is 3.

Constraints:

0 <= nums.length <= 10e5
-10e9 <= nums[i] <= 10e9

----- Your solution below ----

```python=
```