Run-length decompression

前端 未结 6 1538
天涯浪人
天涯浪人 2021-01-26 17:25

CS student here. I want to write a program that will decompress a string that has been encoded according to a modified form of run-length encoding (which I\'ve already written c

6条回答
  •  孤街浪徒
    2021-01-26 18:31

    Assuming that the uncompressed data does never contain digits: Iterate over the string, character by character until you get a digit. Then continue until you have a non-digit (or end of string). The digits inbetween can be parsed to an integer as others already stated:

    int count = Integer.parseInt(str.substring(start, end));
    

提交回复
热议问题