Skip to content

Commit e14cd76

Browse files
committed
feat: solve contains-duplicate
1 parent 8901b1d commit e14cd76

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contains-duplicate/GangBean.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.Arrays;
2+
import java.util.stream.Collectors;
3+
4+
class Solution {
5+
public boolean containsDuplicate(int[] nums) {
6+
/***
7+
compare length of array and length of set.
8+
O(n) given that n is length of array nums
9+
*/
10+
return nums.length > Arrays.stream(nums).boxed().collect(Collectors.toSet()).size();
11+
}
12+
}

0 commit comments

Comments
 (0)