couldn’t find where i am going wrong
Piyush_maical_park
Swati, I have edited your code, try to submit now, I havent use the flag variable … I have used normal algorithm only in the code, If you didnt understood any changes in the code, pls let me know…
Why at the end we are doing m=m+1 and in starting why we have condition if(s<k) then break, it should be if(s<=0) break;
m=m+1, is the condition we have included, because it is given in the question that whenever you encounter “#” it means that the particular row is blocked and hence you need to move in next line…
and also in the question it is also given that if strength at any point is less than k, then you will not traverse further and hence the answer will be No. I hope this clarifys your doubt now.
Then why it is not i=i+1 because we are using i for iteration over rows. With m=m+1 we are increasing number of rows.I tried submitting code with i=i+1 but it is giving wrong ans and with m=m+1 it is giving correct answer.
Yes, it wont give correct answer for i=i+1, because you are already traversing the array elements, using the condition i++ and j++ in the loops, so thts why for moving to the next row, you need to write m=m+1 only, only then your code will work correctly… I hope you understood
Since you arent replying anything now, I am marking this doubt as resolved, You can reopen it if you face any issues…