Given an array of characters, compress it in-place.
The length after compression must always be smaller than or equal to the original array.
Every element of the array should be a character (not int) of length 1.
After you are done modifying the input array in-place, return the new length of the array.
Could you solve it using only O(1) extra space?
count and say strategy to solve this problem, which means look for the next position to see if it equals. Also we use two pointer, one moves faster, another to mark the position actually arrived. In addition, we have to care about the case 2 (just contain one element, which means no number we need to add).
// time:O(n) space:O(1)