> For the complete documentation index, see [llms.txt](https://interviews.woojiahao.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://interviews.woojiahao.com/other-technical-topics/general-problem-solving.md).

# General Problem Solving

{% hint style="info" %}
This list is not exhaustive! If you wish to contribute more techniques, please email me at <woojiahao1234@gmail.com>
{% endhint %}

1. Finding the median of data: focus on the definition of a median and model the solution after it
2. Sub-array problems: think about using sliding windows discussed under [Arrays](/data-structures/arrays.md)
3. Sub-sequence problems: think about sorting (if possible)
4. $$O(n \log n)$$ upper bound (found using [Runtime Predictions](/other-technical-topics/runtime-predictions.md))
   1. Divide and conquer, similar to merge sort
   2. [Arrays](/data-structures/arrays.md) manipulation + [Binary Search](/algorithms/binary-search.md) such as prefix sums + binary search
   3. [Sorting](/algorithms/sorting.md) + operations on sorted array
   4. [Segment Trees](/data-structures/graphs/trees/segment-trees.md)+ iterating over all ranges
   5. Applying the sweep line algorithm if there are [Intervals](/algorithms/intervals.md) + events
5. Minimum/maximum across queries: try using [Heaps](/data-structures/graphs/trees/heaps.md) or [Double Ended Queues](/data-structures/queues/double-ended-queues.md)
   1. [Heaps](/data-structures/graphs/trees/heaps.md) can be used to track the minimum during any query
   2. [Double Ended Queues](/data-structures/queues/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"
