Skip to content

Instantly share code, notes, and snippets.

View Palakkgoyal's full-sized avatar
🏠
Working from home

Palak Goyal Palakkgoyal

🏠
Working from home
  • India
  • 12:14 (UTC -12:00)
View GitHub Profile
@Palakkgoyal
Palakkgoyal / Duplicates.java
Created November 14, 2022 11:16
Leetcode question of sorting
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;
}