Challenge string compression | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Challenge string compression

Write a method that compress a string by the counts of consecutive chars. For example : aaabbbbccd - > a3b4c2d You can assume the string contains only letters. Have fun!

16th Feb 2018, 3:22 PM
Nitzan
Nitzan - avatar
11 Answers
16th Feb 2018, 6:59 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
16th Feb 2018, 6:12 PM
LukArToDo
LukArToDo - avatar
+ 11
@nitzan Do you mean on consecutive repeating characters? For example, what is output for : "aaabbcddddad"? Output 1: a3b2cd4ad Output 2: a4b2cd5
16th Feb 2018, 4:04 PM
LukArToDo
LukArToDo - avatar
18th Feb 2018, 10:52 AM
r8w9
r8w9 - avatar
+ 4
16th Feb 2018, 4:04 PM
J Domingo Jiménez J
J Domingo Jiménez J - avatar
+ 3
Yes I mean consecutive
16th Feb 2018, 5:28 PM
Nitzan
Nitzan - avatar
+ 2
https://code.sololearn.com/chs3l5N0ocxz/?ref=app
17th Feb 2018, 11:47 AM
Andreas
Andreas - avatar
17th Feb 2018, 12:35 PM
VcC
VcC - avatar
+ 1
Didn't see that
16th Feb 2018, 6:53 PM
Nitzan
Nitzan - avatar