The same slow write / fast read machine as LC 27, with one
extra idea: what you compare against. Sorting puts equal values side by side, so a value is worth
keeping exactly when it differs from the last value you actually
kept — nums[write − 1], not
nums[read-1]. The invariant carries the proof: nums[0, write) is
sorted and duplicate-free after every step, so the comparison only ever needs one look back.
nums[write-1] — the form that survives the jump to LC 80.