# 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](https://interviews.woojiahao.com/data-structures/arrays "mention")
3. Sub-sequence problems: think about sorting (if possible)
4. $$O(n \log n)$$ upper bound (found using [runtime-predictions](https://interviews.woojiahao.com/other-technical-topics/runtime-predictions "mention"))
   1. Divide and conquer, similar to merge sort
   2. [arrays](https://interviews.woojiahao.com/data-structures/arrays "mention") manipulation + [binary-search](https://interviews.woojiahao.com/algorithms/binary-search "mention") such as prefix sums + binary search
   3. [sorting](https://interviews.woojiahao.com/algorithms/sorting "mention") + operations on sorted array
   4. [segment-trees](https://interviews.woojiahao.com/data-structures/graphs/trees/segment-trees "mention")+ iterating over all ranges
   5. Applying the sweep line algorithm if there are [intervals](https://interviews.woojiahao.com/algorithms/intervals "mention") + events
5. Minimum/maximum across queries: try using [heaps](https://interviews.woojiahao.com/data-structures/graphs/trees/heaps "mention") or [double-ended-queues](https://interviews.woojiahao.com/data-structures/queues/double-ended-queues "mention")
   1. [heaps](https://interviews.woojiahao.com/data-structures/graphs/trees/heaps "mention") can be used to track the minimum during any query
   2. [double-ended-queues](https://interviews.woojiahao.com/data-structures/queues/double-ended-queues "mention") can be used to represent the current maximum (as the front) and potential maximums (subsequent elements) in the event where the current maximum "expires"


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://interviews.woojiahao.com/other-technical-topics/general-problem-solving.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
