why do i get wrong answers?

My pc ran this code but in codechef it’s showing wrong answer. Can someone tell me what’s wrong?
Here’s the link to question

Here’s the link to my solution

There are two mistakes you have made…

  1. you need to initialize d for each test case…
  2. for(i=0;i<c;i++)
    {
    if(a[i]-a[i+1]==-1)
    {
    d++;
    }
    }
    Here you need to use c - 1…instead of c as you are using i + 1 inside the loop.
    for more information see solution : CodeChef: Practical coding for everyone

this solution is same as yours after fixing above two issues.

2 Likes

Thats not a link to your code or any code.

Here is her solution @akki2200

##\uparrow
Correct answer :slight_smile: