Anyway to improve performace?AC simple java solution using hashset

  • 0
    public boolean containsDuplicate(int[] nums) {
        if(nums.length <= 1) {return false;}
        HashSet<Integer> set = new HashSet<Integer>();
        for(int i = 0; i < nums.length; i++){
            if(!set.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.