this is giving correct answer for the sample case
but showing wrong answer for all 3 test cases
Piyush and Magical Park doubt
You are interpreting the question wrong, basically make changes as per this :
Inside the loop write,
if(S<K)
{
break;
}
Also they have said in question that when u move to another step, strength is reduced by one unit, this thing you havent used in your code. So, make changes as
if(ar[i][j]==ā.ā)
{
S=S-2;
Sā;
}
And also u havent used any such specific condition for ā#ā , so use :
if(ar[i][j]==ā#ā)
{
N=N+1;
}
else
if(ar[i][j]==ā#ā && i==N-1)
{
break;
}