Very Easy to understand JAVA solution


  • 0
    public class Solution {
        public boolean containsDuplicate(int[] nums) {
            Set<Integer> set=new HashSet<>();
            
          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.