過年了,刷個leecoad過年吧
本文爲www.leetcode.com的online judge中151道算法題目的總結。
題目 | 算法 | 數據結構 | 注意事項 |
Clone Graph | BFS | 哈希表 | |
Word Ladder II | BFS | 哈希表 | |
Surrounded Regions | BFS | 矩陣 | |
Word Ladder | BFS | N/A | |
Binary Tree Level Order Traversal | BFS|前序遍歷 | 隊列 | |
Binary Tree Level Order Traversal II | BFS|前序遍歷 | 隊列 | |
Binary Tree Zigzag Level Order Traversal | BFS|前序遍歷 | 隊列 | 每一層順序分別對待 |
Implement strStr() | KMP算法 | N/A | |
Copy List with Random Pointer | N/A | 哈希表 | |
Remove Duplicates from Sorted Array | N/A | 哈希表 | |
Remove Duplicates from Sorted Array II | N/A | 哈希表 | |
Set Matrix Zeroes | N/A | 哈希表 | |
Anagrams | N/A | 哈希表 | |
First Missing Positive | N/A | 哈希表 | |
Two Sum | N/A | 哈希表 | |
Evaluate Reverse Polish Notation | N/A | 堆棧 | |
Largest Rectangle in Histogram | N/A | 堆棧 | 記錄重要位置 |
Minimum Window Substring | N/A | 堆棧 | |
Simplify Path | N/A | 堆棧 | |
Longest Valid Parentheses | N/A | 堆棧 | |
Valid Parentheses | N/A | 堆棧 | 詞法分析 |
Container With Most Water | N/A | 堆棧 | 記錄重要位置 |
Reverse Words in a String | N/A | 堆棧 | 翻轉字符串 |
Best Time to Buy and Sell Stock | N/A | 數組 | |
Best Time to Buy and Sell Stock II | N/A | 數組 | |
Best Time to Buy and Sell Stock III | N/A | 數組 | |
Length of Last Word | N/A | 數組 | |
Search Insert Position | N/A | 數組 | |
Search for a Range | N/A | 數組 | |
Spiral Matrix | N/A | 矩陣 | 簡化爲子問題 |
Spiral Matrix II | N/A | 矩陣 | 簡化爲子問題 |
LRU Cache | N/A | 鏈表 | |
Reorder List | N/A | 鏈表 | 快慢指針&鏈表倒序 |
Linked List Cycle | N/A | 鏈表 | 快慢指針 |
Linked List Cycle II | N/A | 鏈表 | 快慢指針 |
Reverse Linked List II | N/A | 鏈表 | |
Partition List | N/A | 鏈表 | |
Remove Duplicates from Sorted List | N/A | 鏈表 | |
Remove Duplicates from Sorted List II | N/A | 鏈表 | |
Merge Two Sorted Lists | N/A | 鏈表 | |
Rotate List | N/A | 鏈表 | 快慢指針 |
Reverse Nodes in k-Group | N/A | 鏈表 | |
Swap Nodes in Pairs | N/A | 鏈表 | |
Remove Nth Node From End of List | N/A | 鏈表 | 快慢指針 |
Text Justification | N/A | 隊列 | |
Candy | N/A | N/A | 簡化爲子問題 |
Valid Palindrome | N/A | N/A | 首尾指針 |
Plus One | N/A | N/A | 模擬加法運算 |
Valid Number | N/A | N/A | 詞法分析 |
Add Binary | N/A | N/A | 模擬加法運算 |
Insert Interval | N/A | N/A | |
Merge Intervals | N/A | N/A | |
Multiply Strings | N/A | N/A | 模擬乘法運算 |
Trapping Rain Water | N/A | N/A | |
Valid Sudoku | N/A | N/A | |
Roman to Integer | N/A | N/A | |
Integer to Roman | N/A | N/A | |
Palindrome Number | N/A | N/A | |
Reverse Integer | N/A | N/A | |
ZigZag Conversion | N/A | N/A | |
Add Two Numbers | N/A | N/A | 模擬加法運算 |
Median of Two Sorted Arrays | N/A | N/A | |
String to Integer (atoi) | STL函數 | N/A | |
Next Permutation | STL經典算法 | N/A | |
Recover Binary Search Tree | 中序遍歷 | 二叉樹 | |
3Sum | 二分查找 | N/A | |
3Sum Closest | 二分查找 | N/A | |
4Sum | 二分查找 | N/A | |
Single Number | 位運算 | N/A | |
Single Number II | 位運算 | N/A | |
Construct Binary Tree from Preorder and Inorder Traversal | 前序中序遍歷 | N/A | |
Binary Tree Preorder Traversal | 前序遍歷 | 二叉樹 | |
Flatten Binary Tree to Linked List | 前序遍歷 | 二叉樹 | |
Interleaving String | 動態規劃 | 二叉樹 | |
Unique Binary Search Trees | 動態規劃 | 二叉樹 | |
Word Break | 動態規劃 | N/A | |
Word Break II | 動態規劃 | N/A | |
Palindrome Partitioning | 動態規劃 | N/A | |
Palindrome Partitioning II | 動態規劃 | N/A | |
Triangle | 動態規劃 | N/A | |
Distinct Subsequences | 動態規劃 | N/A | |
Decode Ways | 動態規劃 | N/A | |
Scramble String | 動態規劃 | N/A | |
Maximal Rectangle | 動態規劃 | N/A | |
Edit Distance | 動態規劃 | N/A | |
Climbing Stairs | 動態規劃 | N/A | |
Minimum Path Sum | 動態規劃 | N/A | |
Unique Paths | 動態規劃 | N/A | |
Unique Paths II | 動態規劃 | N/A | |
Jump Game | 動態規劃 | N/A | |
Jump Game II | 動態規劃 | N/A | |
Maximum Subarray | 動態規劃 | N/A | |
Wildcard Matching | 動態規劃 | N/A | |
Substring with Concatenation of All Words | 動態規劃 | N/A | |
Sort List | 合併排序 | 鏈表 | 快慢指針 |
Merge Sorted Array | 合併排序 | N/A | |
Construct Binary Tree from Inorder and Postorder Traversal | 後序中序遍歷 | N/A | |
Binary Tree Postorder Traversal | 後續遍歷 | 二叉樹 | |
Combinations | 回溯 | N/A | |
Permutation Sequence | 回溯 | N/A | |
N-Queens | 回溯 | N/A | |
N-Queens II | 回溯 | N/A | |
Permutations | 回溯 | N/A | |
Permutations II | 回溯 | N/A | |
Combination Sum | 回溯 | N/A | |
Combination Sum II | 回溯 | N/A | |
Sudoku Solver | 回溯 | N/A | |
Longest Substring Without Repeating Characters | 回溯 | N/A | |
Max Points on a Line | 循環遍歷 | N/A | 排除相同的點 |
Longest Common Prefix | 循環遍歷 | N/A | |
Longest Palindromic Substring | 循環遍歷 | N/A | |
Insertion Sort List | 插入排序 | 鏈表 | |
Rotate Image | 矢量旋轉與平移 | N/A | |
Longest Consecutive Sequence | 類BFS | 哈希表 | |
Search in Rotated Sorted Array | 類二分查找 | N/A | |
Search in Rotated Sorted Array II | 類二分查找 | N/A | 特殊考慮相等數據 |
Sqrt(x) | 類二分查找 | N/A | |
Pow(x, n) | 類二進制 | N/A | |
Divide Two Integers | 類二進制 | N/A | |
Gas Station | 類合併排序 | N/A | |
Merge k Sorted Lists | 類外排序 | N/A | |
Sort Colors | 類快速排序 | N/A | |
Remove Element | 類快速排序 | N/A | |
Search a 2D Matrix | 類楊氏矩陣 | N/A | |
Restore IP Addresses | 揹包問題 | N/A | |
Sum Root to Leaf Numbers | 遞歸 | 二叉樹 | |
Binary Tree Maximum Path Sum | 遞歸 | 二叉樹 | |
opulating Next Right Pointers in Each Node | 遞歸 | 二叉樹 | |
Populating Next Right Pointers in Each Node II | 遞歸 | 二叉樹 | |
Path Sum | 遞歸 | 二叉樹 | |
Path Sum II | 遞歸 | 二叉樹 | |
Maximum Depth of Binary Tree | 遞歸 | 二叉樹 | |
Minimum Depth of Binary Tree | 遞歸 | 二叉樹 | |
Balanced Binary Tree | 遞歸 | 二叉樹 | |
Symmetric Tree | 遞歸 | 二叉樹 | |
Same Tree | 遞歸 | 二叉樹 | |
Validate Binary Search Tree | 遞歸 | 二叉樹 | |
Unique Binary Search Trees II | 遞歸 | 二叉樹 | |
Binary Tree Inorder Traversal | 遞歸 | 二叉樹 | |
Pascal's Triangle | 遞歸 | N/A | |
Pascal's Triangle II | 遞歸 | N/A | |
Convert Sorted List to Binary Search Tree | 遞歸 | N/A | 快慢指針&反中序遍歷 |
Convert Sorted Array to Binary Search Tree | 遞歸 | N/A | 反中序遍歷 |
Subsets | 遞歸 | N/A | |
Subsets II | 遞歸 | N/A | |
Gray Code | 遞歸 | N/A | |
Word Search | 遞歸 | N/A | |
Count and Say | 遞歸 | N/A | |
Generate Parentheses | 遞歸 | N/A | |
Letter Combinations of a Phone Number | 遞歸 | N/A | |
Regular Expression Matching | 遞歸 | N/A |
URL:http://blog.csdn.net/lanxu_yy/article/details/17848219