insertIndex
and i
to 1.i
is less than the length of the array:
a. If nums[i]
is not equal to nums[i - 1]
, it is a unique element.
b. Assign nums[insertIndex]
to nums[i]
to place the unique element at the correct position.
c. Increment insertIndex
.
d. Increment i
.insertIndex
as the count of unique elements.