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 52e77d9 commit df78dc2Copy full SHA for df78dc2
1 file changed
contains-duplicate/juhui-jeong.java
@@ -0,0 +1,38 @@
1
+/*
2
+
3
+// 첫번째 풀이
4
+class Solution {
5
+ public boolean containsDuplicate(int[] nums) {
6
+ for (int i=0; i < nums.length; i++) {
7
+ for (int j=i+1; j < nums.length; j++) {
8
+ if (nums[i] == nums[j]) return true;
9
+ }
10
11
+ return false;
12
13
+}
14
15
+// 두번째 풀이
16
17
18
+ Set set = new HashSet<Integer>();
19
20
+ set.add(nums[i]);
21
22
23
+ if (set.size() != nums.length) return true;
24
25
26
27
28
+*/
29
30
31
32
+ Set<Integer> set = new HashSet<>();
33
34
+ if (!set.add(nums[i])) return true;
35
36
37
38
0 commit comments