Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,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` 位。

- 重复上述 3 ~ 4 步,直到 `fast` 等于数组长度。
Expand Down