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
https://www.codechef.com/problems/KOL16J
Here’s the link to my solution
https://www.codechef.com/submit/KOL16J

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 : https://www.codechef.com/viewsolution/18639155

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: