What the error in this code..it is failing few of the test cases


I made the changes. Please check it.

we dont have check sr<er and sc<ec condition???

one more thing
just a general question
on submitting code multiple times marks are given on the basis max marks obtained or for the first submission only.

Actually I have added a variable curr which checks if all the elements of the matrix are done or not. When it is equal to the number of elements in the matrix, we simply break out of the loop. It is easier this way than to add extra conditions.

Marks given depends on the best submission till now. You can submit any number of times.

okay thankyou so much!!!got it

Welcome. Please mark your doubt as resolved now.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hello @sneha23 you have raised the doubt again tell me what is the problem that you are facing?

actually i wanted to know why are we adding this if(curr==c) condition everytime…i mean i dont understand even why prateek sir added those two conditions in the last two for loops

@sneha23 in this condition we are checking whether the number of elements are not greater then total number of elements in the array.
total number of elements are m*n.
and everytime we are incrementing the curr for printing every element of the array.
if at any point we find that total elements we have printed is equal to the elements in the array the it will break at that point only.

ok understood and why prateek sir added those if(sr<er) conditions

@sneha23 by this we are checking that we should not cross the row then the ending row.

then why didnt we add there in while loop onlu

@sneha23 you have raised the doubt twice could you please share the line number where you are talking about and the code as well.


line 10
and i want to ask why didnt we add those if condition there only in line 10

@sneha23 there is no need of line 10 in this code.
they have added but it would have worked fine without it as well.

ok thankyou so much!

@sneha23 can i mark this as resolved?