[Huawei OD Unified Exam B Paper | 100 points] A decompression of string compression representation (C++ Java JavaScript Python)

topic description

  • There is a simple compression algorithm: for a string consisting of all lowercase English letters, compress the part with more than two consecutive identical letters into a continuous number plus the letter, and keep the other parts unchanged.
  • Example: The string "aaabbccccd" is compressed into the string "3abb4cd".
  • Please write a decompression function to judge whether it is a legally compressed string according to the input string.
  • If the input is legal, output the decompressed string, otherwise output the string " !error " to report the error.

enter description

  • Enter a line, which is an ASCII string, the length of which will not exceed 100 characters, and the use case guarantees that the length of the output string will also not exceed 100 characters.

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130926368