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 8031e40 commit 4212d9bCopy full SHA for 4212d9b
longest-consecutive-sequence/JEONGBEOMKO.java
@@ -0,0 +1,24 @@
1
+package week01.longest_consecutive_sequence;
2
+
3
+import java.util.HashMap;
4
+import java.util.Map;
5
6
+public class Solution {
7
8
+ public boolean containsDuplicate(int[] nums) {
9
10
+ Map<Integer, Integer> countMap = new HashMap<>();
11
12
+ for (int i = 0; i < nums.length; i++) {
13
+ countMap.put(nums[i], countMap.getOrDefault(nums[i] , 0) + 1);
14
+ }
15
16
+ for (Map.Entry<Integer, Integer> map : countMap.entrySet()) {
17
+ if (map.getValue() >= 2) {
18
+ return true;
19
20
21
22
+ return false;
23
24
+}
0 commit comments