I don't understand..same code, first submission shows time limited exceeds, second accepted...

  • 0
    public class Solution {
    public boolean containsDuplicate(int[] nums) {
        if(nums.length<=1) return false;
        Set<Integer> set = new HashSet<>();
        for(int i=0;i<nums.length;i++){
            if(set.add(nums[i])==false) return true;
        return false;


  • 0

    me too. And if I submit again after changing some methods(the same function) . this happen again!

Log in to reply

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