基本信息
源码名称:leetcode详解.pdf 经典算法 带目录
源码大小:0.98M
文件格式:.pdf
开发语言:Java
更新时间:2021-01-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
leetcode详解 经典算法 各种思路解析 带目录
目录 第 1 章 编程技巧 1 第 2 章 线性表 2 2.1 数组 . . . . . . . . . . . . . . . 2 2.1.1 Remove Duplicates from Sorted Array . . . 2 2.1.2 Remove Duplicates from Sorted Array II . . 3 2.1.3 Search in Rotated Sorted Array . . . . . . 5 2.1.4 Search in Rotated Sorted Array II . . . . . 6 2.1.5 Median of Two Sorted Arrays . . . . . . . . . . 7 2.1.6 Longest Consecutive Sequence . . . . . . . . 8 2.1.7 3Sum . . . . . . . . . . . 9 2.1.8 3Sum Closest . . . . . . 11 2.1.9 4Sum . . . . . . . . . . . 12 2.1.10 Remove Element . . . . 14 2.1.11 Next Permutation . . . . 15 2.1.12 Permutation Sequence . 17 2.1.13 Valid Sudoku . . . . . . 19 2.1.14 Trapping Rain Water . . 21 2.1.15 Rotate Image . . . . . . 24 2.1.16 Plus One . . . . . . . . . 25 2.1.17 Climbing Stairs . . . . . 26 2.1.18 Gray Code . . . . . . . . 27 2.1.19 Set Matrix Zeroes . . . . 30 2.1.20 Gas Station . . . . . . . 32 2.1.21 Candy . . . . . . . . . . 33 2.1.22 Single Number . . . . . 34 2.1.23 Single Number II . . . . 34 2.2 单链表 . . . . . . . . . . . . . . 36 2.2.1 Add Two Numbers . . . 36 2.2.2 Reverse Linked List II . . 37 2.2.3 Partition List . . . . . . 38 2.2.4 Remove Duplicates from Sorted List . . . . . 39 2.2.5 Remove Duplicates from Sorted List II . . . 40 2.2.6 Rotate List . . . . . . . . 42 2.2.7 Remove Nth Node From End of List . . . . 43 2.2.8 Swap Nodes in Pairs . . 44 2.2.9 Reverse Nodes in kGroup . . . . . . . . . . 45 2.2.10 Copy List with Random Pointer . . . . . . . . . . 46 第 3 章 字符串 48 3.1 Valid Palindrome . . . . . . . . 48 3.2 Implement strStr() . . . . . . . . 49 3.3 String to Integer (atoi) . . . . . . 51 3.4 Add Binary . . . . . . . . . . . . 52 3.5 Longest Palindromic Substring . 53 3.6 Regular Expression Matching . . 57 3.7 Wildcard Matching . . . . . . . 58 ii 目录 iii 3.8 Longest Common Prefix . . . . 60 3.9 Valid Number . . . . . . . . . . 61 3.10 Integer to Roman . . . . . . . . 63 3.11 Roman to Integer . . . . . . . . 64 3.12 Count and Say . . . . . . . . . . 65 3.13 Anagrams . . . . . . . . . . . . 66 3.14 Simplify Path . . . . . . . . . . . 67 3.15 Length of Last Word . . . . . . . 68 第 4 章 栈和队列 70 4.1 栈 . . . . . . . . . . . . . . . . . 70 4.1.1 Valid Parentheses . . . . 70 4.1.2 Longest Valid Parentheses . . . . . . . . . . 71 4.1.3 Largest Rectangle in Histogram . . . . . . . . 72 4.2 队列 . . . . . . . . . . . . . . . 74 第 5 章 树 75 5.1 二叉树的遍历 . . . . . . . . . . 75 5.1.1 Binary Tree Level Order Traversal . . . . . . 75 5.1.2 Binary Tree Level Order Traversal II . . . . . 77 5.1.3 Binary Tree Zigzag Level Order Traversal . 79 5.1.4 Binary Tree Inorder Traversal . . . . . . . . 81 5.1.5 Recover Binary Search Tree . . . . . . . . . . . 82 5.1.6 Same Tree . . . . . . . . 84 5.1.7 Symmetric Tree . . . . . 85 5.1.8 Balanced Binary Tree . . 86 5.1.9 Flaen Binary Tree to Linked List . . . . . . . 87 5.1.10 Populating Next Right Pointers in Each Node II . . . . . . . . . . . . . 89 5.2 二叉树的构建 . . . . . . . . . . 91 5.2.1 Construct Binary Tree from Preorder and Inorder Traversal . . . . . 91 5.2.2 Construct Binary Tree from Inorder and Postorder Traversal . . . . . 92 5.3 二叉查找树 . . . . . . . . . . . 93 5.3.1 Unique Binary Search Trees . . . . . . . . . . . 93 5.3.2 Unique Binary Search Trees II . . . . . . . . . . 95 5.3.3 Validate Binary Search Tree . . . . . . . . . . . 96 5.3.4 Convert Sorted Array to Binary Search Tree . 97 5.3.5 Convert Sorted List to Binary Search Tree . . . 98 5.4 二叉树的递归 . . . . . . . . . . 99 5.4.1 Minimum Depth of Binary Tree . . . . . . . . 100 5.4.2 Maximum Depth of Binary Tree . . . . . . . . 101 5.4.3 Path Sum . . . . . . . . 102 5.4.4 Path Sum II . . . . . . . 103 5.4.5 Binary Tree Maximum Path Sum . . . . . . . . 104 5.4.6 Populating Next Right Pointers in Each Node . 105 5.4.7 Sum Root to Leaf Numbers . . . . . . . . . . . 106 iv 目录 第 6 章 排序 108 6.1 Merge Sorted Array . . . . . . . 108 6.2 Merge Two Sorted Lists . . . . . 109 6.3 Merge k Sorted Lists . . . . . . . 109 6.4 First Missing Positive . . . . . . 110 6.5 Sort Colors . . . . . . . . . . . . 111 第 7 章 查找 114 7.1 Search for a Range . . . . . . . . 114 7.2 Search Insert Position . . . . . . 115 7.3 Search a 2D Matrix . . . . . . . 116 第 8 章 暴力枚举法 118 8.1 Subsets . . . . . . . . . . . . . . 118 8.1.1 递归 . . . . . . . . . . . 118 8.1.2 迭代 . . . . . . . . . . . 120 8.2 Subsets II . . . . . . . . . . . . . 121 8.2.1 递归 . . . . . . . . . . . 121 8.2.2 迭代 . . . . . . . . . . . 124 8.3 Permutations . . . . . . . . . . . 125 8.3.1 next_permutation() . . . 125 8.3.2 重新实现 next_permutation() . . . . . . . . . . 125 8.3.3 递归 . . . . . . . . . . . 126 8.4 Permutations II . . . . . . . . . 127 8.4.1 next_permutation() . . . 127 8.4.2 重新实现 next_permutation() . . . . . . . . . . 127 8.4.3 递归 . . . . . . . . . . . 127 8.5 Combinations . . . . . . . . . . 129 8.5.1 递归 . . . . . . . . . . . 129 8.5.2 迭代 . . . . . . . . . . . 130 8.6 Leer Combinations of a Phone Number . . . . . . . . . 130 8.6.1 递归 . . . . . . . . . . . 131 8.6.2 迭代 . . . . . . . . . . . 132 第 9 章 广度优先搜索 133 9.1 Word Ladder . . . . . . . . . . . 133 9.2 Word Ladder II . . . . . . . . . . 135 9.3 Surrounded Regions . . . . . . . 137 9.4 小结 . . . . . . . . . . . . . . . 138 9.4.1 适用场景 . . . . . . . . 138 9.4.2 思考的步骤 . . . . . . . 138 9.4.3 代码模板 . . . . . . . . 139 第 10 章 深度优先搜索 142 10.1 Palindrome Partitioning . . . . . 142 10.2 Unique Paths . . . . . . . . . . . 145 10.2.1 深搜 . . . . . . . . . . . 145 10.2.2 备忘录法 . . . . . . . . 146 10.2.3 动规 . . . . . . . . . . . 146 10.2.4 数学公式 . . . . . . . . 147 10.3 Unique Paths II . . . . . . . . . 148 10.3.1 备忘录法 . . . . . . . . 148 10.3.2 动规 . . . . . . . . . . . 149 10.4 N-eens . . . . . . . . . . . . 150 10.5 N-eens II . . . . . . . . . . . 152 10.6 Restore IP Addresses . . . . . . 153 10.7 Combination Sum . . . . . . . . 154 10.8 Combination Sum II . . . . . . . 156 10.9 Generate Parentheses . . . . . . 157 10.10 Sudoku Solver . . . . . . . . . . 158 10.11 Word Search . . . . . . . . . . . 160 10.12 小结 . . . . . . . . . . . . . . . 162 10.12.1 适用场景 . . . . . . . . 162 10.12.2 思考的步骤 . . . . . . . 162 10.12.3 代码模板 . . . . . . . . 163 10.12.4 深搜与回溯法的区别 . 164 10.12.5 深搜与递归的区别 . . . 164 目录 v 第 11 章 分治法 166 11.1 Pow(x,n) . . . . . . . . . . . . . 166 11.2 Sqrt(x) . . . . . . . . . . . . . . 167 第 12 章 贪心法 168 12.1 Jump Game . . . . . . . . . . . . 168 12.2 Jump Game II . . . . . . . . . . 169 12.3 Best Time to Buy and Sell Stock 171 12.4 Best Time to Buy and Sell Stock II 172 12.5 Longest Substring Without Repeating Characters . . . . . . . 173 12.6 Container With Most Water . . 174 第 13 章 动态规划 175 13.1 Triangle . . . . . . . . . . . . . 175 13.2 Maximum Subarray . . . . . . . 176 13.3 Palindrome Partitioning II . . . 178 13.4 Maximal Rectangle . . . . . . . 179 13.5 Best Time to Buy and Sell Stock III . . . . . . . . . . . . . . . . . 180 13.6 Interleaving String . . . . . . . . 181 13.7 Scramble String . . . . . . . . . 183 13.8 Minimum Path Sum . . . . . . . 188 13.9 Edit Distance . . . . . . . . . . . 191 13.10 Decode Ways . . . . . . . . . . 193 13.11 Distinct Subsequences . . . . . 194 13.12 Word Break . . . . . . . . . . . 195 13.13 Word Break II . . . . . . . . . . 196 第 14 章 图 198 14.1 Clone Graph . . . . . . . . . . . 198 第 15 章 细节实现题 201 15.1 Reverse Integer . . . . . . . . . 201 15.2 Palindrome Number . . . . . . . 202 15.3 Two Sum . . . . . . . . . . . . . 203 15.4 Insert Interval . . . . . . . . . . 204 15.5 Merge Intervals . . . . . . . . . 205 15.6 Minimum Window Substring . . 206 15.7 Multiply Strings . . . . . . . . . 208 15.8 Substring with Concatenation of All Words . . . . . . . . . . . 211 15.9 Pascal’s Triangle . . . . . . . . . 212 15.10 Pascal’s Triangle II . . . . . . . 213 15.11 Spiral Matrix . . . . . . . . . . 214 15.12 Spiral Matrix II . . . . . . . . . 215 15.13 ZigZag Conversion . . . . . . . 217 15.14 Divide Two Integers . . . . . . 218 15.15 Text Justification . . . . . . . . 219