String Compression
Description
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa
would become a2b1c5a3
.
If the "compressed" string would not become smaller than the original string, your method should return the original string.
You can assume the string has only upper and lower case letters (a-z).Have you met this question in a real interview? YesProblem Correction
Example
Example 1:
Example 2:
分析
遇到cur不同就压入list cur+str(cnt)。 最后比较结果和原数组哪个长
Last updated