problem:https://hack.codingblocks.com/contests/c/537/107
soln:https://ide.codingblocks.com/s/38578
this is not working when in a string there are consecutive characters of length 1
ie. if the string is aabbccd-------->output=a2b2c2d1
but if the string is aabbcd-------->Output=a2b2c112 instead of a2b2c1d1
String compression (challenges-strings)
Hey Kanika, actually this isn’t the problem because its giving correct output for aaabbccds. Your code goes wrong in this else block
else{
if(count>0){
str[j]=char(count+48);
j++;
}
currChar=str[i];
str[j]=str[i];
j++;
count=1;
}
Work on your logic for the else block i have mentioned from your code.
i am unable to figure out the mistake
can you help me with my code
The problem in your code is you are updating output in same array… So, make an another array and store the output in that array. It will work.