Skip to content

Commit

Permalink
Time: 2 ms (96.6%), Space: 59.5 MB (7.65%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-S-Sahu committed Oct 21, 2024
1 parent 957065e commit d93131b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 0287-find-the-duplicate-number/0287-find-the-duplicate-number.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution {
public int findDuplicate(int[] nums) {
int count[] = new int[nums.length];
for (int num: nums) {
if (count[num] == 0) count[num]++;
else return num;
}

return -1;
}
}

0 comments on commit d93131b

Please sign in to comment.