Skip to content

Commit 7d761f2

Browse files
authored
Create Find the Duplicate Number
1 parent d6359c5 commit 7d761f2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Find the Duplicate Number

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.Arrays;
2+
3+
class Solution {
4+
public int findDuplicate(int[] nums) {
5+
Arrays.sort(nums);
6+
7+
for(int i = 0; i<nums.length-1; i++){
8+
if(nums[i]==nums[i+1]){
9+
return nums[i];
10+
}
11+
}
12+
13+
return 0;
14+
}
15+
}

0 commit comments

Comments
 (0)