Skip to content

Commit

Permalink
Update 01.Array-Two-Pointers.md
Browse files Browse the repository at this point in the history
  • Loading branch information
itcharge committed Mar 6, 2023
1 parent 9643e1c commit 116e32b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ return 合适的值
1. 定义两个快慢指针 `slow``fast`。其中 `slow` 指向去除重复元素后的数组的末尾位置。`fast` 指向当前元素。
2.`slow` 在后, `fast` 在前。令 `slow = 0``fast = 1`
3. 比较 `slow` 位置上元素值和 `fast` 位置上元素值是否相等。
- 如果不相等,则将 `slow` 后移一位,将 `fast` 指向位置的元素复制到 `slow` 位置上。
- 如果不相等,则将 `slow` 右移一位,将 `fast` 指向位置的元素复制到 `slow` 位置上。
4.`fast` 右移 `1` 位。
5. 重复上述 3 ~ 4 步,直到 `fast` 等于数组长度。
6. 返回 `slow + 1` 即为新数组长度。
Expand Down

0 comments on commit 116e32b

Please sign in to comment.