can’t understand how I will skip some rows/columns if I put SR<ER or SC<EC in while loop
Spiral print 2-Dimensional Array
You will have 4 for loops each for printing - start row, end column, end row, start column.
And after each loop, we will increase or decrease the variables suitably so that elements are not repeated.
For example, lets say initially SR=0, ER=m-1, SC=0, EC=n-1
So for printing first column, we run a loop from SR to ER and print arr[i][SC]. And we increment SC so we will not repeat any element. And like this we will have 3 more loops.
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.