Given a sorted list, remove duplicates in place so each value appears once, keeping order. Return the new length k; the first k elements of the list must be the unique values. Use O(1) extra space.
Then implement allow_two(nums): the same, but each value may appear at most twice.