Java Solution - HashMap

  • 0

    public class Solution {
    public boolean containsDuplicate(int[] nums) {
    // Hash Table
    HashSet<Integer> set = new HashSet<Integer>();

        // Loop through nums
        for(int n : nums){
            if(set.contains(n)) return true;
        return false;


Log in to reply

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