diff --git a/blogs/Algorithm/剑指 Offer/数组相关.md b/blogs/Algorithm/剑指 Offer/数组相关.md index a8763e6..8cbe7dd 100644 --- a/blogs/Algorithm/剑指 Offer/数组相关.md +++ b/blogs/Algorithm/剑指 Offer/数组相关.md @@ -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/) ```java