I have seen few other videos but everyone started explaining with the written code. You were the only one who has explained the approach and then started coding. Explained in a very brilliant manner. More power to you.
you explained it soooo well! I was stuck and my code was getting insanely complicated. I watched your video and maybe 5 seconds in I had a new way of approaching the problem. So I stopped watching and coded everything on my own based on your hint of an approach, and it worked!!! Runtime: 40 ms Memory Usage: 13.6 MB
Wow, code is just like saying normally in English. Nowhere felt it was difficult. That was really a very good way of explaining sir. Thanks for making it easy. 👏
Your Explanation is really nice. I want to add something to the solution Since we are printing the string in a fixed pattern, We can do it so without using variable dir while ( top < down || left < right ) 1.Print left to right & top++ 2.Print top to down & right-- 3.Print right to left & down-- 4.Print down to top & left++ Thanks for the explanation
No you cannot, you have to do it one by one while checking condition for each direction. I suggest you to dry run. and also your while condition is also wrong. Dry run on this test case: row: 3, col: 5 6 6 2 28 2 12 26 3 28 7 22 25 3 4 23
It's my first time to be on this channel and I immediately subscribe this channel. This is the best explanation I got. It was easy to understand as logic was already explained before the code.
amazing video dude, i was needing this but filling the array from right to left. With your video and some of reverse engineering for my case makes this method works very well . your teaching style just blow up my mind i understood everything you tell, you explain in a simply way .even if i speak an other language just keep making this good work ^^
Even simpler code with lesser if conditions and without directions mat = [[ 1, 2, 3,], [5, 6, 7], [9, 10, 11], [13, 14, 15]] top, bottom, left, right = 0, len(mat)-1, 0, len(mat[0])-1 while(top left: for i in range(bottom, top-1, -1): print mat[i][left] left += 1
I was solving this question using the same idea you have presented here. I was getting some failed test cases. I used if statements. Saw your video. Used if...elseif statement. Code ran like a rocket. Thanks for explaining the solution is the easiest way possible
very clear explanation .......If i don't understand any leetcode problem, the first thing I do is to search in your channel.....Thank you so much.....keep posting more solutions
Thanks for this explanation; it was so clear! It's beautiful to see how a seemingly complicated problem can be explained in a simple way if the problem is broken down into simple steps as you did!
Thanks a lot very well explained I got this question suddenly in an interview after preparing so much on dp and LinkedList tree I got stuck in this I was devastated anyways now I am sure I can solve this every time.
Very good explanation !! I watched many other videos but this is by far the most apt explanation. The code seemed easy post understanding the concept you so very well explained!
To traverse matrix in any manner we just need to write nested loops (their count will be equal to total turns) ... Only we need to work on defining the loop variable limits only in terms of number of rows, columns and a variable i .
I have seen few other videos but everyone started explaining with the written code. You were the only one who has explained the approach and then started coding. Explained in a very brilliant manner. More power to you.
Thanks
you explained it soooo well! I was stuck and my code was getting insanely complicated. I watched your video and maybe 5 seconds in I had a new way of approaching the problem. So I stopped watching and coded everything on my own based on your hint of an approach, and it worked!!! Runtime: 40 ms
Memory Usage: 13.6 MB
Nice 😊
3D spiral ata hai kya aapko?
@@lakshaysingla2754 Mujhe toh 2D he Tough laga
@@hhhhhhhhh963 yaar wo to hai but hamare college walo ne 3D spiral de diya test mai karne ko
@Jiny Song on which platform you run the program
Yesterday, I got rejected in final round for not solving this problem. That's why I'm here 🙋♂️.
Now you know it :)
Same here bro
@@rashidixit1168 :o
which comapny?
@@titanofchaos Zoho On-Campus
I have watched many videos on this ,but none of them had given clarity for me..but this one gives me the understand of the trick in easy way
before watching this video I couldn't believe that i can understand this approach to this problem. You made it so simple.
the simplicity of this solution just blew my mind!
Wow, code is just like saying normally in English. Nowhere felt it was difficult. That was really a very good way of explaining sir. Thanks for making it easy. 👏
Welcome :)
Amazing bro, awesome video. I was watching on my browser, I logged in just to like your video. You made it so simple man. WOW
Thanks :)
Your Explanation is really nice.
I want to add something to the solution
Since we are printing the string in a fixed pattern,
We can do it so without using variable dir
while ( top < down || left < right )
1.Print left to right & top++
2.Print top to down & right--
3.Print right to left & down--
4.Print down to top & left++
Thanks for the explanation
Right 👍🏼
after each printing check the while condition again
that you are incrementing for eg after top++ check whether top
No you cannot, you have to do it one by one while checking condition for each direction. I suggest you to dry run. and also your while condition is also wrong.
Dry run on this test case:
row: 3, col: 5
6 6 2 28 2 12 26 3 28 7 22 25 3 4 23
Bro ur way of explaining it with 0,1,2,3 direction solved my every doubt of this question.
Nice 😊
i really like your teaching style ,mind blowing u understood us in a simplest form i have seen ever
thanks bhaiya 😊😊
Welcome 😃
Bro you teach the approach and logic so well. Many TH-camrs simply jump into coding without explanations
It's my first time to be on this channel and I immediately subscribe this channel. This is the best explanation I got. It was easy to understand as logic was already explained before the code.
amazing video dude, i was needing this but filling the array from right to left. With your video and some of reverse engineering for my case makes this method works very well . your teaching style just blow up my mind i understood everything you tell, you explain in a simply way .even if i speak an other language just keep making this good work ^^
Thanks :)
Even simpler code with lesser if conditions and without directions
mat = [[ 1, 2, 3,],
[5, 6, 7],
[9, 10, 11],
[13, 14, 15]]
top, bottom, left, right = 0, len(mat)-1, 0, len(mat[0])-1
while(top left:
for i in range(bottom, top-1, -1):
print mat[i][left]
left += 1
Literally you are a great person..What an explanation..Thank you soooo much.
Welcome :)
I've worked for 5 hrs and wasnt able to solve this your approach is great and i sloved it with ease. THANK YOU!!!!!
Welcome :)
You are fantastic, such a mind blowing explanation ..please keep it up ..coding gets very easy by listening to your explanation and Thankyou so much
Welcome :)
It helps me to explore the new way of solving the problem..
this is best explanation I have ever seen Thank you so much sir. I understood everything
Best explanation ever. I usually don't comment on videos, but this is the best!
Thanks for letting me know :)
what a lovely explanation and a very easy approach to traverse a matrix spirally
thank you and loved to watch more videos
Welcome :)
This is the best channel for any explainationof code thankyou so much
Welcome :)
U r such an awesome person ..thank you for this code... god bless you
the best explanation i've found for the problem, thank you!
I was solving this question using the same idea you have presented here. I was getting some failed test cases. I used if statements. Saw your video. Used if...elseif statement. Code ran like a rocket. Thanks for explaining the solution is the easiest way possible
Welcome :)
very clear explanation .......If i don't understand any leetcode problem, the first thing I do is to search in your channel.....Thank you so much.....keep posting more solutions
Thank you for your explanation . After watching this I'm able write the program without copying the code
Thank you, this is the easiest approach i have seen so far and well explained
The best explanation on entire youtube!! Hats off sir! 💜
wow! what a wonderful explanation. saying thanks is not enough. please continue the good work for the community
Thanks
Thanks Bro. You made this question really easy. I was really frustrated. Thanks for the help.
Welcome :)
OMG this one is amazing man! Highly appriciated. Got me another way of approaching a problem Thanks. Kudos!
This is the best explanation I have ever seen Thank you so much sir
Thanks for this explanation; it was so clear! It's beautiful to see how a seemingly complicated problem can be explained in a simple way if the problem is broken down into simple steps as you did!
You explained in such a beautiful manner thank you...!!!
Welcome :)
Thank you so much! So easy to understand when you explain it!
Welcome :)
I never thought it is as simple as this
Nice :)
Thank u , you explained the problem very well, i was struggling to understand the solution before watching your video
Thanks a lot very well explained I got this question suddenly in an interview after preparing so much on dp and LinkedList tree I got stuck in this I was devastated anyways now I am sure I can solve this every time.
Nice :)
which company's interview btw?
really nice brother ! this is one of the best class that I have ever seen.
Thanks :)
Excellent explanation with Clear manner
Thanks 😊
Love your work. Would you be able to make video for this ? Largest Rectangle in Histogram
I will make it. But currently I am doing dynamic programming. After that I can do.
I understand completely in an easy way can you tell how we can approach our own like these Matrix problems(transpose...etc)
The best explanation ever... thanks a lots 👍
just awsome made my code just after first 3 min of viedo .
Your explanation is so easy... Thx..
Welcome 😊
Easy to understand and easy to code after you understand !!
:)
You made it look very easy . Thanks a lot !
Your all video tutorials are awesome !!
Thanks :)
One of best Algorithm i had ever seen
Great ❤️
Thanks a lot for the video....clear and awesome explanation.....keep making such videos
They are really helpful
Very good explanation !! I watched many other videos but this is by far the most apt explanation. The code seemed easy post understanding the concept you so very well explained!
To traverse matrix in any manner we just need to write nested loops (their count will be equal to total turns) ... Only we need to work on defining the loop variable limits only in terms of number of rows, columns and a variable i .
Amazing explanation I got the approach will code it myself ,to get a grasp
Great
The way u have explained the concept is amazing. I coded it without any help. Thanks :)
Thanks sir . Love your work . Salute from Punjab !!
Thanks paji :)
bro you earned my respect and a sub 🤩 , i here by acknowledge you as my sensei
My Honor :)
Beautifully explained and clean code
Very much intutive and amazing approach
Was able to solve all the variations of spiral matrix in Leetcode after watching this video
Brilliant explanation, very easy to understand and remember the approach. Big thanks!
Soo good ! Legends always make it look soo easy !
Thanks 😅
Brilliant form of explanation 👌👏👍
Thanks
thank you very much for uploading such videos for us for free
Welcome
a huge thanks to you . everything is perfect. you saved my day
Wow what a neat explanation hats off 👏 thanks. Though I was patiently waiting for while condition😉
Haha 😂 you can apply it now 😜
amazing bhai.... your explaination is the always best
Thanks :)
Now I've solved this problem. Thank you
so simple explanation for a tricky question like this
Depicted the approach very well. Thanks :)
Welcome :)
this is a really good trick , thanks for explaining it to so clearly
Actually you forgot to explain that initial while condition.
While(top
Yea... That's why I added in text :P
while(top
It was the best solution i found in youtube
👌🏽
You are a freaking genius!!
Thank you sir , gratitude to your work 👏
Welcome :)
best explanation in whole youtube
i have easily understand great explanation😍😍😍😍😍
Crystal clear explanation. Thanks a lot
You are welcome!
Amazing explanation! Thank you!
Welcome
best video bhai. Although, there is also a recursive approach to solve this problem, but I liked this.
Made it simple. Thanks a lot
Welcome :)
this is such a beautiful explanation that it cleared my doubt in one go. can't thank you enough for this. keep up the good work .lots of respect.
best explanation on internet
:)
You forgot to fill in the while condition. Am I right in thinking (left=right=top=down) will be the while condition to terminate the loop?
Really great explanation bro...
Please keep making videos on important problems like this....
Sure :)
Loved the explanation! Thanks
Thank you so much, that was very useful
Welcome :)
I always struggled with this problem. This is a superb method and great explanation. :)
Thanks 😊
Adding one thing, after every loop we have to dir ++;
unless it never in next direction
Great Explanation, Thank you !!!
Welcome :)
amazing!! you make me like algorithms
Super duper explanation sir. 💯🤩
Thanks
Great explain. Did you clarify the condition for while statement? Could it be while top
Yea right :)
Absolute Explaination BUDDY :}
u explained really well :)
Thanks 😊
Can I get the java code,Sir? I'm facing problems..errors executing my code on the IDE
You can find on geeksforgeeks
DAMN bro!! Great Explanation, keep doing this great work!!
Excellent explanation!
Thanks 😀
thanks u so much man, for such a nice and easy explaination :)