> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0026_remove_duplicates_from_sorted_array/slt.md).

# 思路1 就地算法

注意，这道题的返回结果使用引用传出去。

我们用new\_tail来作为已经整理好的没有重复元素的数组的最后一个索引。然后用i去找后面的元素，如果重复就跳过，如果i和new\_tail的元素不同，则把i上的元素放到new\_tail后面。时间复杂度为O(n),空间复杂度为O(1)。
