#Program NamePatternTimeSpaceKey IdeaLevel
1containsDuplicateHashSetO(n)O(n)Insert into a set; if the element already exists, a duplicate is found.Simple
2groupAnagramsHashMap + SortingO(n·L·logL)O(n·L)Use sorted string as canonical key so all anagrams map to the same bucket.Middle
3longestConsecutiveHashSetO(n)O(n)Only start counting a sequence when num-1 is absent (the sequence head).Middle