I am trying to solve the problem following problem.
Here is the link to my solution.
The problem statement does not mention you need to lower case the string, but in the give test case it lower case the output so I tried with and without the lower case. The code in the solution above gives the exact same output for the given input. I tried increasing the string length. But it didn’t help.
Here is a solution in C++ that got accepted:
I don’t see anything different from what I have done other than the language being in C++. I also read a char before reading the string :
scanf("%c",&string); // clean buffer
I added that because the scanf on the string was not working I searched online and learned that after reading an int you need to read one byte to clean the buffer (read the breakline from the last scanf). I added that and it started reading the string properly.
Please help. I want to understand what I am doing wrong in case I face a similar problem in the future.
Thanks in advance.