Why I am getting wrong output on submitting?

I m getting right o/p on sample tc but wrong in 3 cases on submitting ?

Hello @namandubey20,

Please, share your code.
Steps:

  1. Paste your code on https://ide.codingblocks.com/.
  2. Save your code there.
  3. Share the URL generated.

Hello @namandubey20,

Problem:
Your code is only compressing for a,b,c,d and s.

You are required to create a generalized code that works for each character.
Example 1:
eeffgghh
Your Output:
s0
Expected Output:
e2f2g2h2

Example 2:
aaffaaggg
Your Output:
s4
Expected Output:
a2f2a2g3

Hope, this would help.
Let me know if you face any issue.
Give a like if you are satisfied.

Than do I have to write 26 if else or case statements for 26 alphabates ? It will become very long !

Nope @namandubey20,

You don’t have to do that.

  1. You have to check if the previous character and the current character in the string iterating from left to right) are same then increase the count (initially 1).
  2. if the current character is not same as previous character then make the count 1.

count variable is used to store frequency of each character repeating continuously.

How to print the output?
When point 2. occurs, print the previous character and the value of count then, make count 1.

Code:

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.