A walkthrough of "Longest Increasing Subsequence": why the natural DFS with backtracking solution blows up exponentially, and how dropping the in-progress sequence in favor of two indices makes the same recursion memoizable in O(n²) time.
A walkthrough of "Longest Increasing Subsequence": why the natural DFS with backtracking solution blows up exponentially, and how dropping the in-progress sequence in favor of two indices makes the same recursion memoizable in O(n²) time.
A deeper look at "Contains Duplicate": why the brute force and sorting approaches fall short, how a hash set gets you to linear time, and when a plain boolean array beats hashing altogether.
A walkthrough of "Two Sum": why checking every pair is wasteful, and how reframing the problem around a complement value lets a single HashMap pass find the answer in linear time.
A walkthrough of "Valid Anagram": why sorting two strings works but isn't the cheapest option, and how a character frequency count gets you to linear time with constant extra space.
A walkthrough of "Group Anagrams": why comparing every pair of strings is too slow, and how turning each word into a canonical hash-map key groups them all in linear time.
A walkthrough of "Top K Frequent Elements": why sorting by frequency costs more than it needs to, and how bucket sort gets the answer in linear time by exploiting a bound on how large a frequency can ever be.