Skip to main content

#80 - Duplicate Integers

public Boolean containsDuplicates(List<Integer> nums) {

Set<Integer> seen = new Set<Integer>();

for (Integer i=0; i<nums.size(); i++) {

if (seen.contains(nums[i])) return true;

seen.add(nums[i]);

}

return false;

}

댓글 4개
  1. 8월 31일 오후 10:34

    Abdul Basith - Acknowledging and thanks for brief code.

    I want to shorten it further: 

    #92 - Sorting a List

     

    public List<String> getNamesInAscOrder(List<String> accountNames)

    {

        accountNames?.sort();

        return accountNames ?? accountNames;

     

    }

0/9000