Back to course home
0% completed
Vote For New Content
Java Solution - Sorting
Gokul Rama
Dec 19, 2023
public boolean containsDuplicate(int[] nums) { if (nums == null || nums.length == 0) { return false; } // O(N*logN) - sorting Arrays.sort(nums); // O(N) - iteration for (int i=1; i<nums.length; i++) { if (nums[i-1] == nums[i]) { return true; } } return false; }
0
0
Comments
Comments
chirag guptaa year ago
we can use set and do this in o(n).
On this page
Problem Statement
Examples
Try it yourself