Python solution in HashMap with explanation
class Solution(object):\n        def longestConsecutive(self, nums):\n            """\n            :type nums: List[int]\n            :rtype: int\n            "
    class Solution(object):\n        def longestConsecutive(self, nums):\n            """\n            :type nums: List[int]\n            :rtype: int\n            """\n            unions = {};\n            maxlen = 0;\n            for n in nums:\n                if unions.has_key(n): # duplicate n, skip\n                    continue;\n                start = end = n;\n                if unions.has_key(n+1): # update end if has bigger neighbouring section\n                    end = unions[n+1][1];\n                if unions.has_key(n-1): # update start if has smaller neighbouring section\n                    start = unions[n-1][0];\n                unions[start] = unions[end] = unions[n]=(start,end);\n                maxlen = max(end-start+1, maxlen);\n            return maxlen;\n\nEach section marks its start and end. \nGiven n, get its neighbouring sections (n == section.max+1 or n == section.min-1) in Hashmap in O(1) and meanwhile update their start and end.\nFinally return the max length of sections;
['Python']