------
## 最终结论
```python
def longestConsecutive(nums):
    if not nums:
        return 0
    
    num_set = set(nums)  # Initialize a set to store the elements for quick lookup
    longest_streak = 0
    
    for num in num_set:  # Iterate through each number in the set
        if num - 1 not in num_set:  # Check if it's the start of a sequence
            current_num = num
            current_streak = 1
            
            while current_num + 1 in num_set:  # Count the streak
                current_num += 1
                current_streak += 1
            
            longest_streak = max(longest_streak, current_streak)  # Update the longest streak
    
    return longest_streak

# Example usage:
print(longestConsecutive([100, 4, 200, 1, 3, 2]))  # Output: 4
```