-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem217.java
More file actions
37 lines (33 loc) · 812 Bytes
/
Problem217.java
File metadata and controls
37 lines (33 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.leetcode.problems;
import java.util.HashMap;
import java.util.Map;
class Solution217 {
public boolean containsDuplicate(int[] nums) {
if(nums==null||nums.length==0)
{
return false;
}
Map<Integer, Integer> m = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
if(m.containsKey(nums[i]))
{
m.put(nums[i],m.get(nums[i])+1);
}else{
m.put(nums[i],0);
}
}
for(Integer key:m.keySet())
{
if(m.get(key)>0)
{
return true;
}
}
return false;
}
}
public class Problem217 {
public static void main(String[] args) {
System.out.println("hello, world");
}
}