n - 2.nums[i] is equal to nums[i + 1], double nums[i] and set nums[i + 1] to 0.nonZeroIndex and currentIndex. Set both to 0.currentIndex.nums[currentIndex] is not zero, swap nums[currentIndex] with nums[nonZeroIndex] and increment nonZeroIndex.currentIndex.currentIndex reaches the end of the array.