LeetCode cheatsheet
刷 leetcode 的時候發現官方有提供解題的範本可以做套用,因此利用此範本去針對不同的題目去撰寫
https://leetcode.com/explore/interview/card/cheatsheets/720/resources/4723/
列表
這邊列出全部,會在每一個sheet 邊刷邊補上文章
Two pointers: one input, opposite ends
Two pointers: one input, opposite ends
Two pointers: two inputs, exhaust both
Sliding window
Build a prefix sum
Efficient string building
Linked list: fast and slow pointer
Reversing a linked list
Find number of subarrays that fit an exact criteria
Monotonic increasing stack
Binary tree: DFS (recursive)
Binary tree: DFS (iterative)
Binary tree: BFS
Graph: DFS (recursive)
Graph: DFS (iterative)
Graph: BFS
Find top k elements with heap
Binary search
Binary search: duplicate elements, left-most insertion point
Binary search: duplicate elements, right-most insertion point
Binary search: for greedy problems
If looking for a maximum:
Backtracking
Dynamic programming: top-down memoization
Build a trie
Dijkstra’s algorithm
LeetCode cheatsheet
https://shengshengyang.github.io/2024/02/13/leetcode-cheatsheet/