why this answer get a Time Limit Exceeded(JAVA)


  • 0
    J

    public class Solution {
    public boolean containsDuplicate(int[] nums) {
    Map<Integer,Integer>map=new HashMap<Integer,Integer>();
    for(int i=0;i<nums.length;i++){
    if(map.containsValue(nums[i])){return true;}
    map.put(i,nums[i]);
    }
    return false;
    }
    }


Log in to reply
 

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