DEV Community

schudy
schudy

Posted on

LeetCode 26

I divided the array into two parts: one is processed, the other one is unprocessed.
So I need two pointers (i, j)to go.
'i' is the slow one, it only move forward by 1 if 'j' find different value from 'i'. Then j will copy the value to i's next position. After j finishes all elements in nums, return i+1 as the length result.
Alt Text

Top comments (0)