Approach hintTry it first, then revealHide
Keep a write index for the deduplicated prefix and a read index that scans the array; copy an element forward only when it differs from the last value written. O(n) time, O(1) space.
Keep a write index for the deduplicated prefix and a read index that scans the array; copy an element forward only when it differs from the last value written. O(n) time, O(1) space.