This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public boolean containsDuplicate(int[] nums) { | |
//first we'll sort our array | |
Arrays.sort(nums); | |
//if any number after sorting is equal to number after it, it means that number has a duplicate, hence, we return true | |
for(int k = 0; k < nums.length - 1; k++){ | |
if(nums[k] == nums[k+1]){ | |
return true; | |
} |