longest consecutive elements

This Question Was Asked By Microsoft

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

Write a function solve that have the following parameter(s):
1.) arr = array of integers

Example
Input:
[100, 4, 200, 1, 3, 2]
Output:
4

Explanation
An array [100, 4, 200, 1, 3, 2] is given. The longest consecutive element sequence is [1, 2, 3, 4]. So, it will return 4.

Constraints
• The length of an array should greater than 0 or less than 800.
• The elements in the array should be greater than 0 and less than 1000.