pls check the code https://ide.codingblocks.com/s/480580
Not able to understand the logic
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
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
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.