在好例子网,分享、交流、成长!
您当前所在位置:首页Java 开发实例Java语言基础 → leetcode详解.pdf 经典算法 带目录

leetcode详解.pdf 经典算法 带目录

Java语言基础

下载此实例
  • 开发语言:Java
  • 实例大小:0.98M
  • 下载次数:12
  • 浏览次数:94
  • 发布时间:2021-01-25
  • 实例类别:Java语言基础
  • 发 布 人:commuli
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: leetcode 算法 各种思路

实例介绍

【实例简介】

leetcode详解 经典算法 各种思路解析 带目录

【实例截图】

from clipboard

【核心代码】

目录
第 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 Flaen 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 Leer 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

实例下载地址

leetcode详解.pdf 经典算法 带目录

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警