Race to pick the fastest algorithm: 10 levels of time and space analysis for the optimal solution. An algorithm game for interview prep.
When choosing an algorithm, go for the most efficient approach. Not every problem needs sorting: sometimes a single pass is enough.
A Hash Map gives you O(1) lookup. Instead of an O(n²) nested loop, we can store data in a Map and check whether an element exists in constant time.
Sliding Window is a technique where we keep a fixed-size "window" that slides along the array. Instead of recomputing every time, we only update the difference.
Not all sorting algorithms are equal. Insertion Sort has an O(n) best case on nearly sorted data, because the inner loop barely runs. "Fancier" algorithms like Merge Sort don't take advantage of existing order at all.
A Hash Set gives you has() and add() in O(1). That suits "have I seen this before?" problems, which then need neither sorting nor a nested loop.