Slow/fast writer pointer. Return new length.
Input
3 1 1 2
Output
2 1 2
10 0 0 1 1 1 2 2 3 3 4
5 0 1 2 3 4