LeetCode初级算法练习题4_存在重复元素
时间:2021-03-09 12:58:00
收藏:0
阅读:0
1.我的解题代码
class Solution {
public boolean containsDuplicate(int[] nums) {
boolean flag = false;
HashSet<Integer> set = new HashSet<>();
for(int i:nums){
boolean p = set.add(i);
if(!p){
flag = true;
break;
}
}
return flag;
}
}
评论(0)