9 ms Clean Simple Java Solution


  • 0
    C
    public class Solution {
        public boolean containsDuplicate(int[] nums) {
            Set<Integer> hs = new HashSet<Integer>();
            
            for(int i = 0; i<nums.length; i++){
                if(!hs.add(nums[i])){
                    return true;
                }
            }
            
            return false;
        }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.