| description |
|---|
Consolidating some of the common patterns and problem solving methods you can try when working on problems |
{% hint style="info" %} This list is not exhaustive! If you wish to contribute more techniques, please email me at woojiahao1234@gmail.com {% endhint %}
- Finding the median of data: focus on the definition of a median and model the solution after it
- Sub-array problems: think about using sliding windows discussed under arrays
- Sub-sequence problems: think about sorting (if possible)
-
$$O(n \log n)$$ upper bound (found using runtime-predictions.md)- Divide and conquer, similar to merge sort
- arrays manipulation + binary-search.md such as prefix sums + binary search
- sorting.md + operations on sorted array
- segment-trees.md+ iterating over all ranges
- Applying the sweep line algorithm if there are intervals.md + events
- Minimum/maximum across queries: try using heaps.md or double-ended-queues.md
- heaps.md can be used to track the minimum during any query
- double-ended-queues.md can be used to represent the current maximum (as the front) and potential maximums (subsequent elements) in the event where the current maximum "expires"