9ms JAVA solution


  • 2
    V

    public class Solution {

    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> numbers = new HashSet<Integer>();
        for(int i : nums) {
            if(!numbers.add(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.