Skip to content · ⁨본문 바로가기⁩

Run-length encoding · ⁨런-length 인코딩⁩

English

Run-length encoding

Compress a string by replacing each run of the same character with that character followed by how many times it repeats: aaabbc → a3b2c1. Always write the count, even when it is 1.

Walk the string tracking the current character and how long its run is. When the next character differs, write out the run (character + count) and start a fresh run. Don't forget to write the last run after the loop ends.

한국어

루스 인코딩(RLE)

동일한 문자가 연속해서 나오는 **연속 부분(run)**을 해당 문자와 반복 횟수로 교체하여 압축합니다: aaabbc → a3b2c1. 횟수가 1일 때도 반드시 적으십시오.

현재 문자와 해당 연속 부분의 길이를 추적하며 문장을边走. 다음 문자가 다르면 연속 부분을 출력(문자 + 횟수)하고 새로운 연속 부분을 시작합니다. 루프가 끝난 후 마지막 연속 부분도 잊지 말고 출력하십시오.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP