We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8901b1d commit e14cd76Copy full SHA for e14cd76
contains-duplicate/GangBean.java
@@ -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