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

# Problem Solving

## 1. Clarification of problem, Assumptions(Clarification & Assumption)

* make the requirements&#x20;
* use cases as clear as possible

## 2. Problem Abstraction(High Level)

* identify the key point of the problem, and discrete math model
* abstract the key problem into a well-defined one（找到它实际对应的问题，注意condition）
* with very strict environment requirement
  * data type? data quantitative(positive/ negative)? data scaling (sparse?)
  * unique solution?

## 3. Algorithmic Design(Mid Level + TC\&SC)

* Solve the well-defined problem as efficiently as you can
  * Proposing multiple solutions is very necessary
  * Complexity analysis

## How to ?

* starting from the concrete example to abstract example(题目本身的提炼，找规律)
* There are only a few ways to start the algorithmic design:
  * **Greedy(BFS & maintain a global candidate)**
    * start from the smallest one, and find the next smallest one for k steps
      * so we can utilize the peek() or poll() for each step
      * **Best First Search**
    * global candidate
      * always maintain the k candidates and do necessary updates
    * etc...
  * **Brute Force (DFS all paths)**
    * find all possible things
      * 找好了分解的基准
      * 逻辑解耦
    * find possible optimizations
      * **remove the unnecessary computation**
      * **remove the repeated computation**
  * **Divide & Conquer (pure recursion & real div)**
    * solving problems by using subproblems result
      * binary search?
      * kth smallest in two sorted array
      * quickselect
      * kth smallest in BST

## 4. Practical Concern

* Identify the real-world environment and requirement
* **multiple solutions, necessary modifications**
* **trade-off analysis**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://algo.younglimit.com/summary/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.
