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 53ce7c7 commit f51e1bdCopy full SHA for f51e1bd
contains-duplicate/mumunuu.java
@@ -0,0 +1,28 @@
1
+import java.util.HashSet;
2
+import java.util.Set;
3
+
4
5
+class Solution {
6
7
+ /**
8
+ *
9
+ * Set 판단으로 O(n)
10
11
+ * */
12
+ public boolean containsDuplicate(int[] nums) {
13
14
+ Set<Integer> set = new HashSet<>();
15
16
+ for (int num : nums) {
17
18
+ boolean isAdded = set.add(num);
19
20
+ if (!isAdded) {
21
+ return true;
22
+ }
23
24
25
+ return false;
26
27
28
+}
0 commit comments