Not able to understand the logic

pls check the code https://ide.codingblocks.com/s/480580

sorry this one https://ide.codingblocks.com/s/480581

hello @dipeshpandey2001

u just have to iterate boundaries one by one in anticlockwise fashion.

i.e first u have to iterate and print outer boundaries using 4 for loop
and then next inner 4 boundaries and then next inner boundaries till u have some boundary left .
in the code we are simply simulating the same thing.
pls watch the explanation video , it is explained in detail

pls check this whats the problem https://ide.codingblocks.com/s/480581

its not passing all the test cases

…

u are not taking input array that why.

u need to read input matrix and then it will work

https://ide.codingblocks.com/s/480636 pls check some numbers are printing extra

keep an addtional count variable that will keep track o number of printed elements.

if count reachs N * M then stop printng.

check this

why are we using this && count<(r*c)

and why are we taking count++ everytime?

it is checking that whether we need to print more elemet or not.

everytime we are prinintg one value of array hence we are increment value of count by 1

so as soon as all the elements are printed,we do it so that no extra elements are printed,wright?

yeah right …
…
…

okay;)…

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.