Go O(n) Clean Solution (Explained + Complexity)
Complexity\n- Time complexity: $O(n)$. It consists of building a set in $O(n)$ time + iteration in $O(n)$.\n\n- Space complexity: at worst $n$ elements will be 
# Complexity\n- Time complexity: $O(n)$. It consists of building a set in $O(n)$ time + iteration in $O(n)$.\n\n- Space complexity: at worst $n$ elements will be stored in the set, so $O(n)$.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunc longestConsecutive(nums []int) int {\n    // Construct a set out of the nums array.\n    numsSet := make(map[int]struct{})\n    for _, n := range nums {\n        numsSet[n] = struct{}{}\n    }\n\n    // The answer is stored here.\n    maxSequenceLen := 0\n\n    // Iterate through the set.\n    for n := range numsSet {\n        // We check if n-1 is in the set. If it is, then n is not the beginning of a sequence\n        // and we go to the next number immediately.\n        if _, ok := numsSet[n-1]; !ok {\n            // Otherwise, we increment n in a loop to see if the next consecutive value is stored in nums.\n            seqLen := 1\n            for {\n                if _, ok = numsSet[n+seqLen]; ok {\n                    seqLen++\n                    continue\n                }\n                // When the sequence is over, see if we did better than before.\n                maxSequenceLen = max(seqLen, maxSequenceLen)\n                break\n            }\n        }\n    }\n\n    return maxSequenceLen\n}\n\nfunc max(a, b int) int {\n    if a > b {\n        return a\n    }\n    return b\n}\n\n```
['Array', 'Hash Table', 'Go']