package 剑指Offer.数组中重复的数字;
public class LeetCode {
public static void main(String[] args) {
System.out.println(new Solution().findRepeatNumber(new int[] {2, 3, 1, 0, 2, 5, 3}));
}
}
class Solution {
public int findRepeatNumber(int[] nums) {
int[] is = new int[nums.length];
for (int num : nums) {
is[num]++;
if (is[num] > 1) {
return num;
}
}
return -1;
}
}

网友评论