One test case not passing


Kindly tell mistake as O/P is correct.

hi @ujj1804_1156aee80205d0bf buddy refer this

What is the need of sr<=er , sc<=ec inside if condition in line 34 ,41 bcz if we just use sr<er , sc<ec we will get correct O/P , in the video lecture also we were taught sr<er and sc<ec.

Sir reply plz, whats the reason for the above logic

@ujj1804_1156aee80205d0bf no it should be check for equality do a dry run for 3*4 matrix once on paper with this code

Sir i did so for a 3*4 matrix ,even the O/P is correct. The basic idea of sr<er and sc<ec was that elements must not be printed twice but by using equality we are causing them to be printed twice.

@ujj1804_1156aee80205d0bf actually when u r checking for equality then u r printing once only say you have increased sr after printing first row now sr points to row 2 (not printed just pointing) and say u have matrix of 2 rows only er will be 2 then now if u check sr<er you will not print end row as 2<2 is false but u need to print end row also so 2<=2 will allow for that

Ok so for some test cases like 2*2 matrix we use equality , similarly we will do for anticlockwise spiral print right?

@ujj1804_1156aee80205d0bf yes

Ok thanks doubt clear.

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.