cpp implementation of Remove Duplicates From Sorted Array II