# 0. Introduction

* 解題不建議用recursive，會有stack overflow的問題，工程實作上不常用。若組數沒有很大則可以使用
* 高頻題: Binary Tree, Linked list, Graph and search

  **Tiem complexity 時間複雜度**
* O(1) 极少
* O(logn) 几乎都是二分法
* O(√n) 几乎是分解质因数
* O(n) 高频
* O(nlogn) 一般都可能要排序
* O(n2) 数组，枚举，动态规划
* O(n3) 数组，枚举，动态规划
* O(2n) 与组合有关的搜索
* O(n!) 与排列有关的搜索

## Test code

多用corner case, null, {}, 長度1, 長度0, 全是1, 全是0

## Ask tips

* 是不是BST/binary tree?
* 有沒有parent point?
* 如果給兩個root返回什麼?
* 如果有node不存在，返回什麼?
* e.g. find intersection of 2 linkedlist
  * 有沒有環?
  * 一定有intersection?
  * linkedlist單向? 雙向?
  * 如果一個null一個非null怎麼return?
  * 兩個null怎麼return?

## 問題複雜先寫API

* BFS\_helper/ DFS\_helper


---

# 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://netjimmy.gitbook.io/code-interview-note/master.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.
