My code running well on my system & also giving the desired output,but when i am submitting it gives me wrong answer.Can somebody tell me why i am getting his error.
Here is link to my code:–>
Thanks in Advance
You are storing output of every test case in an array k. The very first thing wrong in your code is :
Why you need this? You get output f a particular test case as count, then you want that k[i]= count. So, why are you putting that for loop?
Second thing wrong in your code is, you have taken size of k as 10 i.e. k. That means k can only store at max 10 numbers. Thus, when the number of test cases exceed 10, what will happen, it’ll not store further answers, but will just print the garbage value when you display the output in the end.
See this test case and its output :
Q : 1
E : 0
A : 1
B : 2
C : 0
W : 0
Q : 1
E : 0
CODECHEF : 2
BBBBB : 1145258561 // garbage value
PQOQD : 1212630597 // garbage value
ABCDEFGHIJKLMNOPQRSTUVWXYZ : 8
You can simply do it this way without using this k array:
if(b==65 || b==68 ||b==79 ||b==80 || b==81 || b==82)