Similar sol doesn't work


  • 0
    R

    Re: Possible solutions.
    Anybody has got some idea, why below solution doesn't work . It says time limit exceeded.

    public boolean containsDuplicate(int[] nums) {

        final List<Integer> li = new ArrayList<Integer>();
        for (int i = 0; i < nums.length; i++) {
    		if(li.contains(nums[i])){
    			return true;
    		}else{
    			li.add(nums[i]);
    		}
    	}
        
        return false;
    }

Log in to reply
 

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