Initialize pointers and iterate through the array:
Initialize j as the pointer for the new array without duplicates, starting at index 1.
Iterate through the array starting from index 1 (i = 1).
Check for duplicates:
Compare the current element nums[i] with the previous element nums[i - 1].
Remove duplicates in-place:
If the current element is not equal to the previous one, update the j-th element with the current element (nums[j] = nums[i]).
Increment the j pointer.
Return the new length:
The final value of j represents the new length of the array without duplicates.
Click for My Solution in Github