|
|
@ -2,6 +2,21 @@ |
|
|
|
数组相关 |
|
|
|
数组相关 |
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[03. 数组中重复的数字](https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof/) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```java |
|
|
|
|
|
|
|
class Solution { |
|
|
|
|
|
|
|
public int findRepeatNumber(int[] nums) { |
|
|
|
|
|
|
|
int[] res = new int[nums.length]; |
|
|
|
|
|
|
|
for (int i : nums) { |
|
|
|
|
|
|
|
res[i]++; |
|
|
|
|
|
|
|
if (res[i] > 1) return i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
[04. 二维数组中的查找](https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/) |
|
|
|
[04. 二维数组中的查找](https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof/) |
|
|
|
|
|
|
|
|
|
|
|
```java |
|
|
|
```java |
|
|
|