443. String Compression
Last updated
Was this helpful?
Last updated
Was this helpful?
Given an array of characters, compress it .
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 , return the new length of the array.
Follow up: Could you solve it using only O(1) extra space?
Example 1:
Example 2:
Example 3:
Note:
All characters have an ASCII value in [35, 126]
.
1 <= len(chars) <= 1000
.