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

Your algorithm should run in O(n) complexity.

Example

```
Input longest Return
[1, 3, 2] [1, 2, 3] 3
[10, 3, 20, 1, 2] [1, 2, 3] 3
```

The follow uses two hash tables. One maps the start to end of all intervals; and the other maps from end to start.