From e5d5f4ef33cb8847e3ae2373e96f5ac86d0d9978 Mon Sep 17 00:00:00 2001 From: Omooo <869759698@qq.com> Date: Tue, 16 Jun 2020 08:19:57 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=95=B0=E7=BB=84=E7=9B=B8=E5=85=B3.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blogs/Algorithm/剑指 Offer/数组相关.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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