I used two-pointer technique that is similar to solve mergesort problems. Also, it's discussed in a Leetcode article https://leetcode.com/articles/two-pointer-technique/

```
public class Solution {
public boolean containsDuplicate(int[] nums) {
if (nums.length <= 1) {
return false;
}
Arrays.sort(nums);
int i = 0;
int j = nums.length -1;
while (i <= j) {
if (nums[i] == nums[i+1]) {
return true;
}
if (nums[j] == nums[j-1]) {
return true;
}
i++;
j--;
}
return false;
}
}
```