# GeetCode Hub

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

You must write an algorithm that runs in `O(n)` time.

Example 1:

```Input: nums = [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: nums = [0,3,7,2,5,8,4,6,0,1]
Output: 9
```

Constraints:

• `0 <= nums.length <= 105`
• `-109 <= nums[i] <= 109`

class Solution { public int longestConsecutive(int[] nums) { } }
{"ft_lang_label":"__label__en","ft_lang_prob":0.7839216,"math_prob":0.99631166,"size":428,"snap":"2021-43-2021-49","text_gpt3_token_len":140,"char_repetition_ratio":0.10377359,"word_repetition_ratio":0.0,"special_character_ratio":0.37616822,"punctuation_ratio":0.2792793,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98657465,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-04T16:14:46Z\",\"WARC-Record-ID\":\"<urn:uuid:f1acbc7b-792d-4409-a899-084dbadaa6ca>\",\"Content-Length\":\"32432\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:20719be8-2135-46d0-9140-e485d4c23652>\",\"WARC-Concurrent-To\":\"<urn:uuid:33ac8a69-e278-4599-bfa6-af0c79233ed2>\",\"WARC-IP-Address\":\"3.22.216.115\",\"WARC-Target-URI\":\"https://geetcode.com/problems/longest-consecutive-sequence/\",\"WARC-Payload-Digest\":\"sha1:63ZZAE5NGVCJ4QKX6S2K2TCPGHPXHID7\",\"WARC-Block-Digest\":\"sha1:GH5OE3UKVVMMGD24ZD37ISDBZDEND62N\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964362999.66_warc_CC-MAIN-20211204154554-20211204184554-00255.warc.gz\"}"}