I have some trouble to understand this part of code:
for (int i = 0; i < nums.length - 2; i++) {
if (i != 0 && nums[i] == nums[i - 1]) continue;
When we started at the first iteration "i=0" :
"nums[0-1] -> nums[-1] ",
is not an Index Out of Bounds? Because the program works, but I don't know why this don't give a IndexOutOfBounds.