> For the complete documentation index, see [llms.txt](https://netjimmy.gitbook.io/code-interview-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://netjimmy.gitbook.io/code-interview-note/master.md).

# 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
