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