https://leetcode.com/problems/contains-duplicate/
hashset 的一道题,没啥好说的,直接实现
public class Solution { public boolean containsDuplicate(int[] nums) { HashSet<Integer> hs = new HashSet<Integer>(); for (Integer i : nums) { if (hs.contains(i)) { return true; } else { hs.add(i); } } return false; } }
Last updated 5 years ago