rewrite leetcode remove duplicates from sorted array