3167. Better Compression of String
You are given a string
compressed
representing a compressed version of a string. The format is a character followed by its frequency. For example,"a3b1a1c2"
is a compressed version of the string"aaabacc"
.We seek a better compression with the following conditions:
- Each character should appear only once in the compressed version.
- The characters should be in alphabetical order.
Return the better compression of
compressed
.Note: In the better version of compression, the order of letters may change, which is acceptable.
1 | class Solution { |