Merge branch 'master' into master
This commit is contained in:
commit
e554a99fbc
@ -1420,7 +1420,6 @@ Java 注解是附加在代码中的一些元信息,用于一些工具在编译
|
|||||||
- Java 不支持多重继承,只能通过实现多个接口来达到相同目的,而 C++ 支持多重继承。
|
- Java 不支持多重继承,只能通过实现多个接口来达到相同目的,而 C++ 支持多重继承。
|
||||||
- Java 不支持操作符重载,虽然可以对两个 String 对象执行加法运算,但是这是语言内置支持的操作,不属于操作符重载,而 C++ 可以。
|
- Java 不支持操作符重载,虽然可以对两个 String 对象执行加法运算,但是这是语言内置支持的操作,不属于操作符重载,而 C++ 可以。
|
||||||
- Java 的 goto 是保留字,但是不可用,C++ 可以使用 goto。
|
- Java 的 goto 是保留字,但是不可用,C++ 可以使用 goto。
|
||||||
- Java 不支持条件编译,C++ 通过 #ifdef #ifndef 等预处理命令从而实现条件编译。
|
|
||||||
|
|
||||||
[What are the main differences between Java and C++?](http://cs-fundamentals.com/tech-interview/java/differences-between-java-and-cpp.php)
|
[What are the main differences between Java and C++?](http://cs-fundamentals.com/tech-interview/java/differences-between-java-and-cpp.php)
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ x ^ x = 0 x & x = x x | x = x
|
|||||||
|
|
||||||
要得到只有第 i 位为 1 的 mask,将 1 向左移动 i-1 位即可,1<<(i-1) 。例如 1<<4 得到只有第 5 位为 1 的 mask :00010000。
|
要得到只有第 i 位为 1 的 mask,将 1 向左移动 i-1 位即可,1<<(i-1) 。例如 1<<4 得到只有第 5 位为 1 的 mask :00010000。
|
||||||
|
|
||||||
要得到 1 到 i 位为 1 的 mask,1<<(i+1)-1 即可,例如将 1<<(4+1)-1 = 00010000-1 = 00001111。
|
要得到 1 到 i 位为 1 的 mask,(1<<i)-1 即可,例如将 (1<<4)-1 = 00010000-1 = 00001111。
|
||||||
|
|
||||||
要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~(1<<(i+1)-1)。
|
要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~((1<<i)-1)。
|
||||||
|
|
||||||
**Java 中的位操作**
|
**Java 中的位操作**
|
||||||
|
|
||||||
|
@ -869,18 +869,20 @@ return -1.
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
public int coinChange(int[] coins, int amount) {
|
public int coinChange(int[] coins, int amount) {
|
||||||
public int change(int amount, int[] coins) {
|
|
||||||
if (coins == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int[] dp = new int[amount + 1];
|
int[] dp = new int[amount + 1];
|
||||||
dp[0] = 1;
|
|
||||||
for (int coin : coins) {
|
for (int coin : coins) {
|
||||||
for (int i = coin; i <= amount; i++) {
|
for (int i = coin; i <= amount; i++) { //将逆序遍历改为正序遍历
|
||||||
dp[i] += dp[i - coin];
|
if (i == coin) {
|
||||||
|
dp[i] = 1;
|
||||||
|
} else if (dp[i] == 0 && dp[i - coin] != 0) {
|
||||||
|
dp[i] = dp[i - coin] + 1;
|
||||||
|
|
||||||
|
} else if (dp[i - coin] != 0) {
|
||||||
|
dp[i] = Math.min(dp[i], dp[i - coin] + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dp[amount];
|
}
|
||||||
|
return dp[amount] == 0 ? -1 : dp[amount];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -902,6 +904,9 @@ Explanation: there are four ways to make up the amount:
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
public int change(int amount, int[] coins) {
|
public int change(int amount, int[] coins) {
|
||||||
|
if (amount == 0 || coins == null || coins.length == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int[] dp = new int[amount + 1];
|
int[] dp = new int[amount + 1];
|
||||||
dp[0] = 1;
|
dp[0] = 1;
|
||||||
for (int coin : coins) {
|
for (int coin : coins) {
|
||||||
@ -999,8 +1004,7 @@ public int combinationSum4(int[] nums, int target) {
|
|||||||
|
|
||||||
题目描述:交易之后需要有一天的冷却时间。
|
题目描述:交易之后需要有一天的冷却时间。
|
||||||
|
|
||||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/83acbb02-872a-4178-b22a-c89c3cb60263.jpg" width="300px"> </div><br>
|
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/ffd96b99-8009-487c-8e98-11c9d44ef14f.png" width="300px"> </div><br>
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public int maxProfit(int[] prices) {
|
public int maxProfit(int[] prices) {
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
|
|
||||||
## 1. 计算在网格中从原点到特定点的最短路径长度
|
## 1. 计算在网格中从原点到特定点的最短路径长度
|
||||||
|
|
||||||
|
[1091. Shortest Path in Binary Matrix(Medium)](https://leetcode.com/problems/shortest-path-in-binary-matrix/)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
[[1,1,0,1],
|
[[1,1,0,1],
|
||||||
[1,0,1,0],
|
[1,0,1,0],
|
||||||
@ -68,12 +70,12 @@
|
|||||||
[1,0,1,1]]
|
[1,0,1,1]]
|
||||||
```
|
```
|
||||||
|
|
||||||
题目描述:1 表示可以经过某个位置,求解从 (0, 0) 位置到 (tr, tc) 位置的最短路径长度。
|
题目描述:0 表示可以经过某个位置,求解从左上角到右下角的最短路径长度。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public int minPathLength(int[][] grids, int tr, int tc) {
|
public int shortestPathBinaryMatrix(int[][] grids) {
|
||||||
final int[][] direction = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
int[][] direction = {{1, -1}, {1, 0}, {1, 1}, {0, -1}, {0, 1}, {-1, -1}, {-1, 0}, {-1, 1}};
|
||||||
final int m = grids.length, n = grids[0].length;
|
int m = grids.length, n = grids[0].length;
|
||||||
Queue<Pair<Integer, Integer>> queue = new LinkedList<>();
|
Queue<Pair<Integer, Integer>> queue = new LinkedList<>();
|
||||||
queue.add(new Pair<>(0, 0));
|
queue.add(new Pair<>(0, 0));
|
||||||
int pathLength = 0;
|
int pathLength = 0;
|
||||||
@ -83,14 +85,14 @@ public int minPathLength(int[][] grids, int tr, int tc) {
|
|||||||
while (size-- > 0) {
|
while (size-- > 0) {
|
||||||
Pair<Integer, Integer> cur = queue.poll();
|
Pair<Integer, Integer> cur = queue.poll();
|
||||||
int cr = cur.getKey(), cc = cur.getValue();
|
int cr = cur.getKey(), cc = cur.getValue();
|
||||||
grids[cr][cc] = 0; // 标记
|
grids[cr][cc] = 1; // 标记
|
||||||
for (int[] d : direction) {
|
for (int[] d : direction) {
|
||||||
int nr = cr + d[0], nc = cc + d[1];
|
int nr = cr + d[0], nc = cc + d[1];
|
||||||
if (nr < 0 || nr >= m || nc < 0 || nc >= n || grids[nr][nc] == 0) {
|
if (nr < 0 || nr >= m || nc < 0 || nc >= n || grids[nr][nc] == 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (nr == tr && nc == tc) {
|
if (nr == m - 1 && nc == n - 1) {
|
||||||
return pathLength;
|
return pathLength + 1;
|
||||||
}
|
}
|
||||||
queue.add(new Pair<>(nr, nc));
|
queue.add(new Pair<>(nr, nc));
|
||||||
}
|
}
|
||||||
@ -501,13 +503,12 @@ Return:
|
|||||||
左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。
|
左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
||||||
private int m, n;
|
private int m, n;
|
||||||
private int[][] matrix;
|
private int[][] matrix;
|
||||||
private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
|
private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
|
||||||
|
|
||||||
public List<int[]> pacificAtlantic(int[][] matrix) {
|
public List<List<Integer>> pacificAtlantic(int[][] matrix) {
|
||||||
List<int[]> ret = new ArrayList<>();
|
List<List<Integer>> ret = new ArrayList<>();
|
||||||
if (matrix == null || matrix.length == 0) {
|
if (matrix == null || matrix.length == 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -530,7 +531,7 @@ public List<int[]> pacificAtlantic(int[][] matrix) {
|
|||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
if (canReachP[i][j] && canReachA[i][j]) {
|
if (canReachP[i][j] && canReachA[i][j]) {
|
||||||
ret.add(new int[]{i, j});
|
ret.add(Arrays.asList(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# 10.1 斐波那契数列
|
# 10.1 斐波那契数列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class Solution {
|
|||||||
|
|
||||||
# 10.2 矩形覆盖
|
# 10.2 矩形覆盖
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6?tpId=13&tqId=11163&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6?tpId=13&tqId=11163&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public int RectCover(int n) {
|
|||||||
|
|
||||||
# 10.3 跳台阶
|
# 10.3 跳台阶
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public int JumpFloor(int n) {
|
|||||||
if (n <= 2)
|
if (n <= 2)
|
||||||
return n;
|
return n;
|
||||||
int pre2 = 1, pre1 = 2;
|
int pre2 = 1, pre1 = 2;
|
||||||
int result = 1;
|
int result = 0;
|
||||||
for (int i = 2; i < n; i++) {
|
for (int i = 2; i < n; i++) {
|
||||||
result = pre2 + pre1;
|
result = pre2 + pre1;
|
||||||
pre2 = pre1;
|
pre2 = pre1;
|
||||||
@ -166,7 +166,7 @@ public int JumpFloor(int n) {
|
|||||||
|
|
||||||
# 10.4 变态跳台阶
|
# 10.4 变态跳台阶
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&tqId=11162&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&tqId=11162&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public int JumpFloorII(int target) {
|
|||||||
|
|
||||||
# 11. 旋转数组的最小数字
|
# 11. 旋转数组的最小数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba?tpId=13&tqId=11159&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba?tpId=13&tqId=11159&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ private int minNumber(int[] nums, int l, int h) {
|
|||||||
|
|
||||||
# 12. 矩阵中的路径
|
# 12. 矩阵中的路径
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c61c6999eecb4b8f88a98f66b273a3cc?tpId=13&tqId=11218&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c61c6999eecb4b8f88a98f66b273a3cc?tpId=13&tqId=11218&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ private char[][] buildMatrix(char[] array) {
|
|||||||
|
|
||||||
# 13. 机器人的运动范围
|
# 13. 机器人的运动范围
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6e5207314b5241fb83f2329e89fdecc8?tpId=13&tqId=11219&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6e5207314b5241fb83f2329e89fdecc8?tpId=13&tqId=11219&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ public int integerBreak(int n) {
|
|||||||
|
|
||||||
# 15. 二进制中 1 的个数
|
# 15. 二进制中 1 的个数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8ee967e43c2c4ec193b040ea7fbb10b8?tpId=13&tqId=11164&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8ee967e43c2c4ec193b040ea7fbb10b8?tpId=13&tqId=11164&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ public int NumberOf1(int n) {
|
|||||||
|
|
||||||
# 16. 数值的整数次方
|
# 16. 数值的整数次方
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00?tpId=13&tqId=11165&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00?tpId=13&tqId=11165&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -626,7 +626,7 @@ public ListNode deleteNode(ListNode head, ListNode tobeDelete) {
|
|||||||
|
|
||||||
# 18.2 删除链表中重复的结点
|
# 18.2 删除链表中重复的结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&tqId=11209&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&tqId=11209&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ public ListNode deleteDuplication(ListNode pHead) {
|
|||||||
|
|
||||||
# 19. 正则表达式匹配
|
# 19. 正则表达式匹配
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/45327ae22b7b413ea21df13ee7d6429c?tpId=13&tqId=11205&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/45327ae22b7b413ea21df13ee7d6429c?tpId=13&tqId=11205&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
# 20. 表示数值的字符串
|
# 20. 表示数值的字符串
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6f8c901d091949a5837e24bb82a731f2?tpId=13&tqId=11206&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6f8c901d091949a5837e24bb82a731f2?tpId=13&tqId=11206&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public boolean isNumeric(char[] str) {
|
|||||||
|
|
||||||
# 21. 调整数组顺序使奇数位于偶数前面
|
# 21. 调整数组顺序使奇数位于偶数前面
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/beb5aa231adc45b2a5dcc5b62c93f593?tpId=13&tqId=11166&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/beb5aa231adc45b2a5dcc5b62c93f593?tpId=13&tqId=11166&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ private void swap(int[] nums, int i, int j) {
|
|||||||
|
|
||||||
# 22. 链表中倒数第 K 个结点
|
# 22. 链表中倒数第 K 个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/529d3ae5a407492994ad2a246518148a?tpId=13&tqId=11167&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/529d3ae5a407492994ad2a246518148a?tpId=13&tqId=11167&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public ListNode FindKthToTail(ListNode head, int k) {
|
|||||||
|
|
||||||
# 23. 链表中环的入口结点
|
# 23. 链表中环的入口结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?tpId=13&tqId=11208&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?tpId=13&tqId=11208&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public ListNode EntryNodeOfLoop(ListNode pHead) {
|
|||||||
|
|
||||||
# 24. 反转链表
|
# 24. 反转链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public ListNode ReverseList(ListNode head) {
|
|||||||
|
|
||||||
# 25. 合并两个排序的链表
|
# 25. 合并两个排序的链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337?tpId=13&tqId=11169&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337?tpId=13&tqId=11169&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public ListNode Merge(ListNode list1, ListNode list2) {
|
|||||||
|
|
||||||
# 26. 树的子结构
|
# 26. 树的子结构
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ private boolean isSubtreeWithRoot(TreeNode root1, TreeNode root2) {
|
|||||||
|
|
||||||
# 27. 二叉树的镜像
|
# 27. 二叉树的镜像
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/564f4c26aa584921bc75623e48ca3011?tpId=13&tqId=11171&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/564f4c26aa584921bc75623e48ca3011?tpId=13&tqId=11171&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ private void swap(TreeNode root) {
|
|||||||
|
|
||||||
# 28 对称的二叉树
|
# 28 对称的二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb?tpId=13&tqId=11211&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb?tpId=13&tqId=11211&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ boolean isSymmetrical(TreeNode t1, TreeNode t2) {
|
|||||||
|
|
||||||
# 29. 顺时针打印矩阵
|
# 29. 顺时针打印矩阵
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a?tpId=13&tqId=11172&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a?tpId=13&tqId=11172&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
# 30. 包含 min 函数的栈
|
# 30. 包含 min 函数的栈
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=13&tqId=11173&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=13&tqId=11173&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public int min() {
|
|||||||
|
|
||||||
# 31. 栈的压入、弹出序列
|
# 31. 栈的压入、弹出序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&tqId=11174&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&tqId=11174&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public boolean IsPopOrder(int[] pushSequence, int[] popSequence) {
|
|||||||
|
|
||||||
# 32.1 从上往下打印二叉树
|
# 32.1 从上往下打印二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/7fe2212963db4790b57431d9ed259701?tpId=13&tqId=11175&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/7fe2212963db4790b57431d9ed259701?tpId=13&tqId=11175&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
|
|||||||
|
|
||||||
# 32.2 把二叉树打印成多行
|
# 32.2 把二叉树打印成多行
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/445c44d982d04483b04a54f298796288?tpId=13&tqId=11213&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/445c44d982d04483b04a54f298796288?tpId=13&tqId=11213&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
|
|||||||
|
|
||||||
# 32.3 按之字形顺序打印二叉树
|
# 32.3 按之字形顺序打印二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/91b69814117f4e8097390d107d2efbe0?tpId=13&tqId=11212&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/91b69814117f4e8097390d107d2efbe0?tpId=13&tqId=11212&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
|
|||||||
|
|
||||||
# 33. 二叉搜索树的后序遍历序列
|
# 33. 二叉搜索树的后序遍历序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/a861533d45854474ac791d90e447bafd?tpId=13&tqId=11176&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/a861533d45854474ac791d90e447bafd?tpId=13&tqId=11176&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ private boolean verify(int[] sequence, int first, int last) {
|
|||||||
|
|
||||||
# 34. 二叉树中和为某一值的路径
|
# 34. 二叉树中和为某一值的路径
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/b736e784e3e34731af99065031301bca?tpId=13&tqId=11177&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/b736e784e3e34731af99065031301bca?tpId=13&tqId=11177&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ private void backtracking(TreeNode node, int target, ArrayList<Integer> path) {
|
|||||||
|
|
||||||
# 35. 复杂链表的复制
|
# 35. 复杂链表的复制
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/f836b2c43afc4b35ad6adc41ec941dba?tpId=13&tqId=11178&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/f836b2c43afc4b35ad6adc41ec941dba?tpId=13&tqId=11178&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public RandomListNode Clone(RandomListNode pHead) {
|
|||||||
|
|
||||||
# 36. 二叉搜索树与双向链表
|
# 36. 二叉搜索树与双向链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ private void inOrder(TreeNode node) {
|
|||||||
|
|
||||||
# 37. 序列化二叉树
|
# 37. 序列化二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/cf7e25aa97c04cc1a68c8f040e71fb84?tpId=13&tqId=11214&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/cf7e25aa97c04cc1a68c8f040e71fb84?tpId=13&tqId=11214&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ private TreeNode Deserialize() {
|
|||||||
|
|
||||||
# 38. 字符串的排列
|
# 38. 字符串的排列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7?tpId=13&tqId=11180&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7?tpId=13&tqId=11180&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ private void backtracking(char[] chars, boolean[] hasUsed, StringBuilder s) {
|
|||||||
|
|
||||||
# 39. 数组中出现次数超过一半的数字
|
# 39. 数组中出现次数超过一半的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/e8a1b01a2df14cb2b228b30ee6a92163?tpId=13&tqId=11181&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/e8a1b01a2df14cb2b228b30ee6a92163?tpId=13&tqId=11181&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
# 3. 数组中重复的数字
|
# 3. 数组中重复的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ private void swap(int[] nums, int i, int j) {
|
|||||||
|
|
||||||
# 4. 二维数组中的查找
|
# 4. 二维数组中的查找
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public boolean Find(int target, int[][] matrix) {
|
|||||||
|
|
||||||
# 5. 替换空格
|
# 5. 替换空格
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/4060ac7e3e404ad1a894ef3e17650423?tpId=13&tqId=11155&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/4060ac7e3e404ad1a894ef3e17650423?tpId=13&tqId=11155&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public String replaceSpace(StringBuffer str) {
|
|||||||
|
|
||||||
# 6. 从尾到头打印链表
|
# 6. 从尾到头打印链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
|||||||
|
|
||||||
# 7. 重建二叉树
|
# 7. 重建二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ private TreeNode reConstructBinaryTree(int[] pre, int preL, int preR, int inL) {
|
|||||||
|
|
||||||
# 8. 二叉树的下一个结点
|
# 8. 二叉树的下一个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public TreeLinkNode GetNext(TreeLinkNode pNode) {
|
|||||||
|
|
||||||
# 9. 用两个栈实现队列
|
# 9. 用两个栈实现队列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=11158&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=11158&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
# 40. 最小的 K 个数
|
# 40. 最小的 K 个数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?tpId=13&tqId=11182&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?tpId=13&tqId=11182&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public ArrayList<Integer> GetLeastNumbers_Solution(int[] nums, int k) {
|
|||||||
|
|
||||||
# 41.1 数据流中的中位数
|
# 41.1 数据流中的中位数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9be0172896bd43948f8a32fb954e1be1?tpId=13&tqId=11216&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9be0172896bd43948f8a32fb954e1be1?tpId=13&tqId=11216&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public Double GetMedian() {
|
|||||||
|
|
||||||
# 41.2 字符流中第一个不重复的字符
|
# 41.2 字符流中第一个不重复的字符
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720?tpId=13&tqId=11207&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720?tpId=13&tqId=11207&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public char FirstAppearingOnce() {
|
|||||||
|
|
||||||
# 42. 连续子数组的最大和
|
# 42. 连续子数组的最大和
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484?tpId=13&tqId=11183&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484?tpId=13&tqId=11183&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ public int FindGreatestSumOfSubArray(int[] nums) {
|
|||||||
|
|
||||||
# 43. 从 1 到 n 整数中 1 出现的次数
|
# 43. 从 1 到 n 整数中 1 出现的次数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6?tpId=13&tqId=11184&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6?tpId=13&tqId=11184&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ private int getDigitAtIndex(int index, int place) {
|
|||||||
|
|
||||||
# 45. 把数组排成最小的数
|
# 45. 把数组排成最小的数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993?tpId=13&tqId=11185&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993?tpId=13&tqId=11185&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ public int longestSubStringWithoutDuplication(String str) {
|
|||||||
|
|
||||||
# 49. 丑数
|
# 49. 丑数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6aa9e04fc3794f68acf8778237ba065b?tpId=13&tqId=11186&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6aa9e04fc3794f68acf8778237ba065b?tpId=13&tqId=11186&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
# 50. 第一个只出现一次的字符位置
|
# 50. 第一个只出现一次的字符位置
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=13&tqId=11187&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=13&tqId=11187&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public int FirstNotRepeatingChar2(String str) {
|
|||||||
|
|
||||||
# 51. 数组中的逆序对
|
# 51. 数组中的逆序对
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/96bd6684e04a44eb80e6a68efc0ec6c5?tpId=13&tqId=11188&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/96bd6684e04a44eb80e6a68efc0ec6c5?tpId=13&tqId=11188&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ private void merge(int[] nums, int l, int m, int h) {
|
|||||||
|
|
||||||
# 52. 两个链表的第一个公共结点
|
# 52. 两个链表的第一个公共结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
|
|||||||
|
|
||||||
# 53. 数字在排序数组中出现的次数
|
# 53. 数字在排序数组中出现的次数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2?tpId=13&tqId=11190&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2?tpId=13&tqId=11190&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ private int binarySearch(int[] nums, int K) {
|
|||||||
|
|
||||||
# 54. 二叉查找树的第 K 个结点
|
# 54. 二叉查找树的第 K 个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a?tpId=13&tqId=11215&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a?tpId=13&tqId=11215&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ private void inOrder(TreeNode root, int k) {
|
|||||||
|
|
||||||
# 55.1 二叉树的深度
|
# 55.1 二叉树的深度
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/435fb86331474282a3499955f0a41e8b?tpId=13&tqId=11191&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/435fb86331474282a3499955f0a41e8b?tpId=13&tqId=11191&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public int TreeDepth(TreeNode root) {
|
|||||||
|
|
||||||
# 55.2 平衡二叉树
|
# 55.2 平衡二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ private int height(TreeNode root) {
|
|||||||
|
|
||||||
# 56. 数组中只出现一次的数字
|
# 56. 数组中只出现一次的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/e02fdb54d7524710a7d664d082bb7811?tpId=13&tqId=11193&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/e02fdb54d7524710a7d664d082bb7811?tpId=13&tqId=11193&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public void FindNumsAppearOnce(int[] nums, int num1[], int num2[]) {
|
|||||||
|
|
||||||
# 57.1 和为 S 的两个数字
|
# 57.1 和为 S 的两个数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/390da4f7a00f44bea7c2f3d19491311b?tpId=13&tqId=11195&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/390da4f7a00f44bea7c2f3d19491311b?tpId=13&tqId=11195&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ public ArrayList<Integer> FindNumbersWithSum(int[] array, int sum) {
|
|||||||
|
|
||||||
# 57.2 和为 S 的连续正数序列
|
# 57.2 和为 S 的连续正数序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe?tpId=13&tqId=11194&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe?tpId=13&tqId=11194&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
|
|||||||
|
|
||||||
# 58.1 翻转单词顺序列
|
# 58.1 翻转单词顺序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3?tpId=13&tqId=11197&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3?tpId=13&tqId=11197&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ private void swap(char[] c, int i, int j) {
|
|||||||
|
|
||||||
# 58.2 左旋转字符串
|
# 58.2 左旋转字符串
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec?tpId=13&tqId=11196&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec?tpId=13&tqId=11196&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ private void swap(char[] chars, int i, int j) {
|
|||||||
|
|
||||||
# 59. 滑动窗口的最大值
|
# 59. 滑动窗口的最大值
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788?tpId=13&tqId=11217&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788?tpId=13&tqId=11217&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public List<Map.Entry<Integer, Double>> dicesSum(int n) {
|
|||||||
|
|
||||||
# 61. 扑克牌顺子
|
# 61. 扑克牌顺子
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public boolean isContinuous(int[] nums) {
|
|||||||
|
|
||||||
# 62. 圆圈中最后剩下的数
|
# 62. 圆圈中最后剩下的数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public int maxProfit(int[] prices) {
|
|||||||
|
|
||||||
# 64. 求 1+2+3+...+n
|
# 64. 求 1+2+3+...+n
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ public int Sum_Solution(int n) {
|
|||||||
|
|
||||||
# 65. 不用加减乘除做加法
|
# 65. 不用加减乘除做加法
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215?tpId=13&tqId=11201&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215?tpId=13&tqId=11201&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ public int Add(int a, int b) {
|
|||||||
|
|
||||||
# 66. 构建乘积数组
|
# 66. 构建乘积数组
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46?tpId=13&tqId=11204&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46?tpId=13&tqId=11204&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public int[] multiply(int[] A) {
|
|||||||
|
|
||||||
# 67. 把字符串转换成整数
|
# 67. 把字符串转换成整数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1277c681251b4372bdef344468e4f26e?tpId=13&tqId=11202&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1277c681251b4372bdef344468e4f26e?tpId=13&tqId=11202&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
BIN
docs/pics/ffd96b99-8009-487c-8e98-11c9d44ef14f.png
Normal file
BIN
docs/pics/ffd96b99-8009-487c-8e98-11c9d44ef14f.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -1420,7 +1420,6 @@ Java 注解是附加在代码中的一些元信息,用于一些工具在编译
|
|||||||
- Java 不支持多重继承,只能通过实现多个接口来达到相同目的,而 C++ 支持多重继承。
|
- Java 不支持多重继承,只能通过实现多个接口来达到相同目的,而 C++ 支持多重继承。
|
||||||
- Java 不支持操作符重载,虽然可以对两个 String 对象执行加法运算,但是这是语言内置支持的操作,不属于操作符重载,而 C++ 可以。
|
- Java 不支持操作符重载,虽然可以对两个 String 对象执行加法运算,但是这是语言内置支持的操作,不属于操作符重载,而 C++ 可以。
|
||||||
- Java 的 goto 是保留字,但是不可用,C++ 可以使用 goto。
|
- Java 的 goto 是保留字,但是不可用,C++ 可以使用 goto。
|
||||||
- Java 不支持条件编译,C++ 通过 #ifdef #ifndef 等预处理命令从而实现条件编译。
|
|
||||||
|
|
||||||
[What are the main differences between Java and C++?](http://cs-fundamentals.com/tech-interview/java/differences-between-java-and-cpp.php)
|
[What are the main differences between Java and C++?](http://cs-fundamentals.com/tech-interview/java/differences-between-java-and-cpp.php)
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ x ^ x = 0 x & x = x x | x = x
|
|||||||
|
|
||||||
要得到只有第 i 位为 1 的 mask,将 1 向左移动 i-1 位即可,1<<(i-1) 。例如 1<<4 得到只有第 5 位为 1 的 mask :00010000。
|
要得到只有第 i 位为 1 的 mask,将 1 向左移动 i-1 位即可,1<<(i-1) 。例如 1<<4 得到只有第 5 位为 1 的 mask :00010000。
|
||||||
|
|
||||||
要得到 1 到 i 位为 1 的 mask,1<<(i+1)-1 即可,例如将 1<<(4+1)-1 = 00010000-1 = 00001111。
|
要得到 1 到 i 位为 1 的 mask,(1<<i)-1 即可,例如将 (1<<4)-1 = 00010000-1 = 00001111。
|
||||||
|
|
||||||
要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~(1<<(i+1)-1)。
|
要得到 1 到 i 位为 0 的 mask,只需将 1 到 i 位为 1 的 mask 取反,即 \~((1<<i)-1)。
|
||||||
|
|
||||||
**Java 中的位操作**
|
**Java 中的位操作**
|
||||||
|
|
||||||
|
@ -994,6 +994,7 @@ public int combinationSum4(int[] nums, int target) {
|
|||||||
|
|
||||||
<div align="center"> <img src="pics/83acbb02-872a-4178-b22a-c89c3cb60263.jpg" width="300px"> </div><br>
|
<div align="center"> <img src="pics/83acbb02-872a-4178-b22a-c89c3cb60263.jpg" width="300px"> </div><br>
|
||||||
|
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public int maxProfit(int[] prices) {
|
public int maxProfit(int[] prices) {
|
||||||
if (prices == null || prices.length == 0) {
|
if (prices == null || prices.length == 0) {
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
|
|
||||||
## 1. 计算在网格中从原点到特定点的最短路径长度
|
## 1. 计算在网格中从原点到特定点的最短路径长度
|
||||||
|
|
||||||
|
[1091. Shortest Path in Binary Matrix(Medium)](https://leetcode.com/problems/shortest-path-in-binary-matrix/)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
[[1,1,0,1],
|
[[1,1,0,1],
|
||||||
[1,0,1,0],
|
[1,0,1,0],
|
||||||
@ -68,12 +70,12 @@
|
|||||||
[1,0,1,1]]
|
[1,0,1,1]]
|
||||||
```
|
```
|
||||||
|
|
||||||
题目描述:1 表示可以经过某个位置,求解从 (0, 0) 位置到 (tr, tc) 位置的最短路径长度。
|
题目描述:0 表示可以经过某个位置,求解从左上角到右下角的最短路径长度。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public int minPathLength(int[][] grids, int tr, int tc) {
|
public int shortestPathBinaryMatrix(int[][] grids) {
|
||||||
final int[][] direction = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
int[][] direction = {{1, -1}, {1, 0}, {1, 1}, {0, -1}, {0, 1}, {-1, -1}, {-1, 0}, {-1, 1}};
|
||||||
final int m = grids.length, n = grids[0].length;
|
int m = grids.length, n = grids[0].length;
|
||||||
Queue<Pair<Integer, Integer>> queue = new LinkedList<>();
|
Queue<Pair<Integer, Integer>> queue = new LinkedList<>();
|
||||||
queue.add(new Pair<>(0, 0));
|
queue.add(new Pair<>(0, 0));
|
||||||
int pathLength = 0;
|
int pathLength = 0;
|
||||||
@ -83,14 +85,14 @@ public int minPathLength(int[][] grids, int tr, int tc) {
|
|||||||
while (size-- > 0) {
|
while (size-- > 0) {
|
||||||
Pair<Integer, Integer> cur = queue.poll();
|
Pair<Integer, Integer> cur = queue.poll();
|
||||||
int cr = cur.getKey(), cc = cur.getValue();
|
int cr = cur.getKey(), cc = cur.getValue();
|
||||||
grids[cr][cc] = 0; // 标记
|
grids[cr][cc] = 1; // 标记
|
||||||
for (int[] d : direction) {
|
for (int[] d : direction) {
|
||||||
int nr = cr + d[0], nc = cc + d[1];
|
int nr = cr + d[0], nc = cc + d[1];
|
||||||
if (nr < 0 || nr >= m || nc < 0 || nc >= n || grids[nr][nc] == 0) {
|
if (nr < 0 || nr >= m || nc < 0 || nc >= n || grids[nr][nc] == 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (nr == tr && nc == tc) {
|
if (nr == m - 1 && nc == n - 1) {
|
||||||
return pathLength;
|
return pathLength + 1;
|
||||||
}
|
}
|
||||||
queue.add(new Pair<>(nr, nc));
|
queue.add(new Pair<>(nr, nc));
|
||||||
}
|
}
|
||||||
@ -501,13 +503,12 @@ Return:
|
|||||||
左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。
|
左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
||||||
private int m, n;
|
private int m, n;
|
||||||
private int[][] matrix;
|
private int[][] matrix;
|
||||||
private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
|
private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
|
||||||
|
|
||||||
public List<int[]> pacificAtlantic(int[][] matrix) {
|
public List<List<Integer>> pacificAtlantic(int[][] matrix) {
|
||||||
List<int[]> ret = new ArrayList<>();
|
List<List<Integer>> ret = new ArrayList<>();
|
||||||
if (matrix == null || matrix.length == 0) {
|
if (matrix == null || matrix.length == 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -530,7 +531,7 @@ public List<int[]> pacificAtlantic(int[][] matrix) {
|
|||||||
for (int i = 0; i < m; i++) {
|
for (int i = 0; i < m; i++) {
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
if (canReachP[i][j] && canReachA[i][j]) {
|
if (canReachP[i][j] && canReachA[i][j]) {
|
||||||
ret.add(new int[]{i, j});
|
ret.add(Arrays.asList(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
notes/pics/ffd96b99-8009-487c-8e98-11c9d44ef14f.png
Normal file
BIN
notes/pics/ffd96b99-8009-487c-8e98-11c9d44ef14f.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
# 10.1 斐波那契数列
|
# 10.1 斐波那契数列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class Solution {
|
|||||||
|
|
||||||
# 10.2 矩形覆盖
|
# 10.2 矩形覆盖
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6?tpId=13&tqId=11163&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/72a5a919508a4251859fb2cfb987a0e6?tpId=13&tqId=11163&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public int RectCover(int n) {
|
|||||||
|
|
||||||
# 10.3 跳台阶
|
# 10.3 跳台阶
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public int JumpFloor(int n) {
|
|||||||
if (n <= 2)
|
if (n <= 2)
|
||||||
return n;
|
return n;
|
||||||
int pre2 = 1, pre1 = 2;
|
int pre2 = 1, pre1 = 2;
|
||||||
int result = 1;
|
int result = 0;
|
||||||
for (int i = 2; i < n; i++) {
|
for (int i = 2; i < n; i++) {
|
||||||
result = pre2 + pre1;
|
result = pre2 + pre1;
|
||||||
pre2 = pre1;
|
pre2 = pre1;
|
||||||
@ -166,7 +166,7 @@ public int JumpFloor(int n) {
|
|||||||
|
|
||||||
# 10.4 变态跳台阶
|
# 10.4 变态跳台阶
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&tqId=11162&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&tqId=11162&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public int JumpFloorII(int target) {
|
|||||||
|
|
||||||
# 11. 旋转数组的最小数字
|
# 11. 旋转数组的最小数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba?tpId=13&tqId=11159&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba?tpId=13&tqId=11159&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ private int minNumber(int[] nums, int l, int h) {
|
|||||||
|
|
||||||
# 12. 矩阵中的路径
|
# 12. 矩阵中的路径
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c61c6999eecb4b8f88a98f66b273a3cc?tpId=13&tqId=11218&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c61c6999eecb4b8f88a98f66b273a3cc?tpId=13&tqId=11218&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ private char[][] buildMatrix(char[] array) {
|
|||||||
|
|
||||||
# 13. 机器人的运动范围
|
# 13. 机器人的运动范围
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6e5207314b5241fb83f2329e89fdecc8?tpId=13&tqId=11219&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6e5207314b5241fb83f2329e89fdecc8?tpId=13&tqId=11219&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ public int integerBreak(int n) {
|
|||||||
|
|
||||||
# 15. 二进制中 1 的个数
|
# 15. 二进制中 1 的个数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8ee967e43c2c4ec193b040ea7fbb10b8?tpId=13&tqId=11164&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8ee967e43c2c4ec193b040ea7fbb10b8?tpId=13&tqId=11164&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ public int NumberOf1(int n) {
|
|||||||
|
|
||||||
# 16. 数值的整数次方
|
# 16. 数值的整数次方
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00?tpId=13&tqId=11165&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00?tpId=13&tqId=11165&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -626,7 +626,7 @@ public ListNode deleteNode(ListNode head, ListNode tobeDelete) {
|
|||||||
|
|
||||||
# 18.2 删除链表中重复的结点
|
# 18.2 删除链表中重复的结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&tqId=11209&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&tqId=11209&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ public ListNode deleteDuplication(ListNode pHead) {
|
|||||||
|
|
||||||
# 19. 正则表达式匹配
|
# 19. 正则表达式匹配
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/45327ae22b7b413ea21df13ee7d6429c?tpId=13&tqId=11205&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/45327ae22b7b413ea21df13ee7d6429c?tpId=13&tqId=11205&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
# 20. 表示数值的字符串
|
# 20. 表示数值的字符串
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6f8c901d091949a5837e24bb82a731f2?tpId=13&tqId=11206&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6f8c901d091949a5837e24bb82a731f2?tpId=13&tqId=11206&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public boolean isNumeric(char[] str) {
|
|||||||
|
|
||||||
# 21. 调整数组顺序使奇数位于偶数前面
|
# 21. 调整数组顺序使奇数位于偶数前面
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/beb5aa231adc45b2a5dcc5b62c93f593?tpId=13&tqId=11166&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/beb5aa231adc45b2a5dcc5b62c93f593?tpId=13&tqId=11166&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ private void swap(int[] nums, int i, int j) {
|
|||||||
|
|
||||||
# 22. 链表中倒数第 K 个结点
|
# 22. 链表中倒数第 K 个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/529d3ae5a407492994ad2a246518148a?tpId=13&tqId=11167&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/529d3ae5a407492994ad2a246518148a?tpId=13&tqId=11167&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public ListNode FindKthToTail(ListNode head, int k) {
|
|||||||
|
|
||||||
# 23. 链表中环的入口结点
|
# 23. 链表中环的入口结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?tpId=13&tqId=11208&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4?tpId=13&tqId=11208&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public ListNode EntryNodeOfLoop(ListNode pHead) {
|
|||||||
|
|
||||||
# 24. 反转链表
|
# 24. 反转链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public ListNode ReverseList(ListNode head) {
|
|||||||
|
|
||||||
# 25. 合并两个排序的链表
|
# 25. 合并两个排序的链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337?tpId=13&tqId=11169&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d8b6b4358f774294a89de2a6ac4d9337?tpId=13&tqId=11169&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public ListNode Merge(ListNode list1, ListNode list2) {
|
|||||||
|
|
||||||
# 26. 树的子结构
|
# 26. 树的子结构
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6e196c44c7004d15b1610b9afca8bd88?tpId=13&tqId=11170&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ private boolean isSubtreeWithRoot(TreeNode root1, TreeNode root2) {
|
|||||||
|
|
||||||
# 27. 二叉树的镜像
|
# 27. 二叉树的镜像
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/564f4c26aa584921bc75623e48ca3011?tpId=13&tqId=11171&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/564f4c26aa584921bc75623e48ca3011?tpId=13&tqId=11171&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ private void swap(TreeNode root) {
|
|||||||
|
|
||||||
# 28 对称的二叉树
|
# 28 对称的二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb?tpId=13&tqId=11211&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb?tpId=13&tqId=11211&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ boolean isSymmetrical(TreeNode t1, TreeNode t2) {
|
|||||||
|
|
||||||
# 29. 顺时针打印矩阵
|
# 29. 顺时针打印矩阵
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a?tpId=13&tqId=11172&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a?tpId=13&tqId=11172&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
# 30. 包含 min 函数的栈
|
# 30. 包含 min 函数的栈
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=13&tqId=11173&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49?tpId=13&tqId=11173&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public int min() {
|
|||||||
|
|
||||||
# 31. 栈的压入、弹出序列
|
# 31. 栈的压入、弹出序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&tqId=11174&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106?tpId=13&tqId=11174&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public boolean IsPopOrder(int[] pushSequence, int[] popSequence) {
|
|||||||
|
|
||||||
# 32.1 从上往下打印二叉树
|
# 32.1 从上往下打印二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/7fe2212963db4790b57431d9ed259701?tpId=13&tqId=11175&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/7fe2212963db4790b57431d9ed259701?tpId=13&tqId=11175&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
|
|||||||
|
|
||||||
# 32.2 把二叉树打印成多行
|
# 32.2 把二叉树打印成多行
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/445c44d982d04483b04a54f298796288?tpId=13&tqId=11213&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/445c44d982d04483b04a54f298796288?tpId=13&tqId=11213&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
|
|||||||
|
|
||||||
# 32.3 按之字形顺序打印二叉树
|
# 32.3 按之字形顺序打印二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/91b69814117f4e8097390d107d2efbe0?tpId=13&tqId=11212&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/91b69814117f4e8097390d107d2efbe0?tpId=13&tqId=11212&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
|
|||||||
|
|
||||||
# 33. 二叉搜索树的后序遍历序列
|
# 33. 二叉搜索树的后序遍历序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/a861533d45854474ac791d90e447bafd?tpId=13&tqId=11176&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/a861533d45854474ac791d90e447bafd?tpId=13&tqId=11176&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ private boolean verify(int[] sequence, int first, int last) {
|
|||||||
|
|
||||||
# 34. 二叉树中和为某一值的路径
|
# 34. 二叉树中和为某一值的路径
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/b736e784e3e34731af99065031301bca?tpId=13&tqId=11177&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/b736e784e3e34731af99065031301bca?tpId=13&tqId=11177&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ private void backtracking(TreeNode node, int target, ArrayList<Integer> path) {
|
|||||||
|
|
||||||
# 35. 复杂链表的复制
|
# 35. 复杂链表的复制
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/f836b2c43afc4b35ad6adc41ec941dba?tpId=13&tqId=11178&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/f836b2c43afc4b35ad6adc41ec941dba?tpId=13&tqId=11178&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public RandomListNode Clone(RandomListNode pHead) {
|
|||||||
|
|
||||||
# 36. 二叉搜索树与双向链表
|
# 36. 二叉搜索树与双向链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/947f6eb80d944a84850b0538bf0ec3a5?tpId=13&tqId=11179&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ private void inOrder(TreeNode node) {
|
|||||||
|
|
||||||
# 37. 序列化二叉树
|
# 37. 序列化二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/cf7e25aa97c04cc1a68c8f040e71fb84?tpId=13&tqId=11214&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/cf7e25aa97c04cc1a68c8f040e71fb84?tpId=13&tqId=11214&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ private TreeNode Deserialize() {
|
|||||||
|
|
||||||
# 38. 字符串的排列
|
# 38. 字符串的排列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7?tpId=13&tqId=11180&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/fe6b651b66ae47d7acce78ffdd9a96c7?tpId=13&tqId=11180&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ private void backtracking(char[] chars, boolean[] hasUsed, StringBuilder s) {
|
|||||||
|
|
||||||
# 39. 数组中出现次数超过一半的数字
|
# 39. 数组中出现次数超过一半的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/e8a1b01a2df14cb2b228b30ee6a92163?tpId=13&tqId=11181&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/e8a1b01a2df14cb2b228b30ee6a92163?tpId=13&tqId=11181&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
# 3. 数组中重复的数字
|
# 3. 数组中重复的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ private void swap(int[] nums, int i, int j) {
|
|||||||
|
|
||||||
# 4. 二维数组中的查找
|
# 4. 二维数组中的查找
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public boolean Find(int target, int[][] matrix) {
|
|||||||
|
|
||||||
# 5. 替换空格
|
# 5. 替换空格
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/4060ac7e3e404ad1a894ef3e17650423?tpId=13&tqId=11155&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/4060ac7e3e404ad1a894ef3e17650423?tpId=13&tqId=11155&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public String replaceSpace(StringBuffer str) {
|
|||||||
|
|
||||||
# 6. 从尾到头打印链表
|
# 6. 从尾到头打印链表
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {
|
|||||||
|
|
||||||
# 7. 重建二叉树
|
# 7. 重建二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ private TreeNode reConstructBinaryTree(int[] pre, int preL, int preR, int inL) {
|
|||||||
|
|
||||||
# 8. 二叉树的下一个结点
|
# 8. 二叉树的下一个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public TreeLinkNode GetNext(TreeLinkNode pNode) {
|
|||||||
|
|
||||||
# 9. 用两个栈实现队列
|
# 9. 用两个栈实现队列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=11158&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&tqId=11158&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
# 40. 最小的 K 个数
|
# 40. 最小的 K 个数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?tpId=13&tqId=11182&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?tpId=13&tqId=11182&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public ArrayList<Integer> GetLeastNumbers_Solution(int[] nums, int k) {
|
|||||||
|
|
||||||
# 41.1 数据流中的中位数
|
# 41.1 数据流中的中位数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/9be0172896bd43948f8a32fb954e1be1?tpId=13&tqId=11216&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/9be0172896bd43948f8a32fb954e1be1?tpId=13&tqId=11216&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public Double GetMedian() {
|
|||||||
|
|
||||||
# 41.2 字符流中第一个不重复的字符
|
# 41.2 字符流中第一个不重复的字符
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720?tpId=13&tqId=11207&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720?tpId=13&tqId=11207&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public char FirstAppearingOnce() {
|
|||||||
|
|
||||||
# 42. 连续子数组的最大和
|
# 42. 连续子数组的最大和
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484?tpId=13&tqId=11183&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/459bd355da1549fa8a49e350bf3df484?tpId=13&tqId=11183&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ public int FindGreatestSumOfSubArray(int[] nums) {
|
|||||||
|
|
||||||
# 43. 从 1 到 n 整数中 1 出现的次数
|
# 43. 从 1 到 n 整数中 1 出现的次数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6?tpId=13&tqId=11184&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/bd7f978302044eee894445e244c7eee6?tpId=13&tqId=11184&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ private int getDigitAtIndex(int index, int place) {
|
|||||||
|
|
||||||
# 45. 把数组排成最小的数
|
# 45. 把数组排成最小的数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993?tpId=13&tqId=11185&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993?tpId=13&tqId=11185&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ public int longestSubStringWithoutDuplication(String str) {
|
|||||||
|
|
||||||
# 49. 丑数
|
# 49. 丑数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6aa9e04fc3794f68acf8778237ba065b?tpId=13&tqId=11186&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6aa9e04fc3794f68acf8778237ba065b?tpId=13&tqId=11186&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
# 50. 第一个只出现一次的字符位置
|
# 50. 第一个只出现一次的字符位置
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=13&tqId=11187&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1c82e8cf713b4bbeb2a5b31cf5b0417c?tpId=13&tqId=11187&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public int FirstNotRepeatingChar2(String str) {
|
|||||||
|
|
||||||
# 51. 数组中的逆序对
|
# 51. 数组中的逆序对
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/96bd6684e04a44eb80e6a68efc0ec6c5?tpId=13&tqId=11188&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/96bd6684e04a44eb80e6a68efc0ec6c5?tpId=13&tqId=11188&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ private void merge(int[] nums, int l, int m, int h) {
|
|||||||
|
|
||||||
# 52. 两个链表的第一个公共结点
|
# 52. 两个链表的第一个公共结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
|
|||||||
|
|
||||||
# 53. 数字在排序数组中出现的次数
|
# 53. 数字在排序数组中出现的次数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2?tpId=13&tqId=11190&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2?tpId=13&tqId=11190&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ private int binarySearch(int[] nums, int K) {
|
|||||||
|
|
||||||
# 54. 二叉查找树的第 K 个结点
|
# 54. 二叉查找树的第 K 个结点
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a?tpId=13&tqId=11215&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a?tpId=13&tqId=11215&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 解题思路
|
## 解题思路
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ private void inOrder(TreeNode root, int k) {
|
|||||||
|
|
||||||
# 55.1 二叉树的深度
|
# 55.1 二叉树的深度
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/435fb86331474282a3499955f0a41e8b?tpId=13&tqId=11191&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/435fb86331474282a3499955f0a41e8b?tpId=13&tqId=11191&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public int TreeDepth(TreeNode root) {
|
|||||||
|
|
||||||
# 55.2 平衡二叉树
|
# 55.2 平衡二叉树
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/8b3b95850edb4115918ecebdf1b4d222?tpId=13&tqId=11192&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ private int height(TreeNode root) {
|
|||||||
|
|
||||||
# 56. 数组中只出现一次的数字
|
# 56. 数组中只出现一次的数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/e02fdb54d7524710a7d664d082bb7811?tpId=13&tqId=11193&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/e02fdb54d7524710a7d664d082bb7811?tpId=13&tqId=11193&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public void FindNumsAppearOnce(int[] nums, int num1[], int num2[]) {
|
|||||||
|
|
||||||
# 57.1 和为 S 的两个数字
|
# 57.1 和为 S 的两个数字
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/390da4f7a00f44bea7c2f3d19491311b?tpId=13&tqId=11195&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/390da4f7a00f44bea7c2f3d19491311b?tpId=13&tqId=11195&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ public ArrayList<Integer> FindNumbersWithSum(int[] array, int sum) {
|
|||||||
|
|
||||||
# 57.2 和为 S 的连续正数序列
|
# 57.2 和为 S 的连续正数序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe?tpId=13&tqId=11194&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe?tpId=13&tqId=11194&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ public ArrayList<ArrayList<Integer>> FindContinuousSequence(int sum) {
|
|||||||
|
|
||||||
# 58.1 翻转单词顺序列
|
# 58.1 翻转单词顺序列
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3?tpId=13&tqId=11197&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/3194a4f4cf814f63919d0790578d51f3?tpId=13&tqId=11197&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ private void swap(char[] c, int i, int j) {
|
|||||||
|
|
||||||
# 58.2 左旋转字符串
|
# 58.2 左旋转字符串
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec?tpId=13&tqId=11196&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/12d959b108cb42b1ab72cef4d36af5ec?tpId=13&tqId=11196&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ private void swap(char[] chars, int i, int j) {
|
|||||||
|
|
||||||
# 59. 滑动窗口的最大值
|
# 59. 滑动窗口的最大值
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788?tpId=13&tqId=11217&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1624bc35a45c42c0bc17d17fa0cba788?tpId=13&tqId=11217&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public List<Map.Entry<Integer, Double>> dicesSum(int n) {
|
|||||||
|
|
||||||
# 61. 扑克牌顺子
|
# 61. 扑克牌顺子
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/762836f4d43d43ca9deb273b3de8e1f4?tpId=13&tqId=11198&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public boolean isContinuous(int[] nums) {
|
|||||||
|
|
||||||
# 62. 圆圈中最后剩下的数
|
# 62. 圆圈中最后剩下的数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public int maxProfit(int[] prices) {
|
|||||||
|
|
||||||
# 64. 求 1+2+3+...+n
|
# 64. 求 1+2+3+...+n
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/7a0da8fc483247ff8800059e12d7caf1?tpId=13&tqId=11200&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ public int Sum_Solution(int n) {
|
|||||||
|
|
||||||
# 65. 不用加减乘除做加法
|
# 65. 不用加减乘除做加法
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215?tpId=13&tqId=11201&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215?tpId=13&tqId=11201&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ public int Add(int a, int b) {
|
|||||||
|
|
||||||
# 66. 构建乘积数组
|
# 66. 构建乘积数组
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46?tpId=13&tqId=11204&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46?tpId=13&tqId=11204&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public int[] multiply(int[] A) {
|
|||||||
|
|
||||||
# 67. 把字符串转换成整数
|
# 67. 把字符串转换成整数
|
||||||
|
|
||||||
[NowCoder](https://www.nowcoder.com/practice/1277c681251b4372bdef344468e4f26e?tpId=13&tqId=11202&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking)
|
[NowCoder](https://www.nowcoder.com/practice/1277c681251b4372bdef344468e4f26e?tpId=13&tqId=11202&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user