Skip to content

Arrays

Problem Complexity Key Pattern
Group Anagrams O(n * k log k) where n = number of strings, k = max string length Grouping items by equivalence class — anagrams, isomorphic strings, etc.
Product Except Self O(n) Prefix/suffix accumulation without division — product, sum, or any
Top K Frequent O(n) Frequency counting + selection — "top K", "most common", "least common".
Two Sum O(n) Any problem asking "find pair with property X" — hash map for O(1) lookups.