A consecutive sequence consists of numbers that appear continuously in increasing order with a difference of 1 between adjacent elements.
The elements do not need to appear next to each other in the original array.
Example 1:
Input: nums = [100,4,200,1,3,2]
Output: 4
Explanation: The longest consecutive sequence is [1, 2, 3, 4], so its length is 4.
Example 2:
Input: nums = [0,3,7,2,5,8,4,6,0,1]
Output: 9
Explanation: The longest consecutive sequence is [0,1,2,3,4,5,6,7,8], so the length becomes 9.
Example 3:
Input: nums = [1,2,0,1]
Output: 3
Explanation: The longest consecutive sequence is [0,1,2], so its length is 3.