Trick for spiral matrix traversal
This video explains a very frequently asked question in programming interviews which is to print the given matrix (either square or rectangular matrix) in a spiral way. My friend was asked this question in microsoft group fly round. This video contains the explanation of the logic and an elegant trick or hack to solve this question elegantly. CODE LINK is given below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
CODE LINK: drive.google.com/open?id=1akK...
Пікірлер: 561
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.
@techdose4u
3 жыл бұрын
Thanks
Yesterday, I got rejected in final round for not solving this problem. That's why I'm here 🙋♂️.
@techdose4u
3 жыл бұрын
Now you know it :)
@rashidixit1168
3 жыл бұрын
Same here bro
@techdose4u
3 жыл бұрын
@@rashidixit1168 :o
@titanofchaos
3 жыл бұрын
which comapny?
@PsSarvna
3 жыл бұрын
@@titanofchaos Zoho On-Campus
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!
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.
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 ^^
@techdose4u
3 жыл бұрын
Thanks :)
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
@techdose4u
4 жыл бұрын
Thanks :)
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. 👏
@techdose4u
3 жыл бұрын
Welcome :)
the simplicity of this solution just blew my mind!
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.
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
@techdose4u
3 жыл бұрын
Nice 😊
@lakshaysingla2754
2 жыл бұрын
3D spiral ata hai kya aapko?
@hhhhhhhhh963
2 жыл бұрын
@@lakshaysingla2754 Mujhe toh 2D he Tough laga
@lakshaysingla2754
2 жыл бұрын
@@hhhhhhhhh963 yaar wo to hai but hamare college walo ne 3D spiral de diya test mai karne ko
@saunaknandi1814
2 жыл бұрын
@Jiny Song on which platform you run the program
OMG this one is amazing man! Highly appriciated. Got me another way of approaching a problem Thanks. Kudos!
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.
The best explanation on entire youtube!! Hats off sir! 💜
Bro you teach the approach and logic so well. Many KZreadrs simply jump into coding without explanations
Brilliant explanation, very easy to understand and remember the approach. Big thanks!
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!
The way u have explained the concept is amazing. I coded it without any help. Thanks :)
Thank you, this is the easiest approach i have seen so far and well explained
i really like your teaching style ,mind blowing u understood us in a simplest form i have seen ever thanks bhaiya 😊😊
@techdose4u
3 жыл бұрын
Welcome 😃
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 .
wow! what a wonderful explanation. saying thanks is not enough. please continue the good work for the community
@techdose4u
2 жыл бұрын
Thanks
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
@techdose4u
4 жыл бұрын
Welcome :)
You made it look very easy . Thanks a lot !
U r such an awesome person ..thank you for this code... god bless you
Literally you are a great person..What an explanation..Thank you soooo much.
@techdose4u
4 жыл бұрын
Welcome :)
what a lovely explanation and a very easy approach to traverse a matrix spirally thank you and loved to watch more videos
@techdose4u
3 жыл бұрын
Welcome :)
the best explanation i've found for the problem, thank you!
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
Great job in explaining in the reasonable speed and in an very understanding manner! :clap
Thank you so much! So easy to understand when you explain it!
@techdose4u
2 жыл бұрын
Welcome :)
dhanyawad mitar. helped right on time.
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
@techdose4u
3 жыл бұрын
Welcome :)
a huge thanks to you . everything is perfect. you saved my day
this is best explanation I have ever seen Thank you so much sir. I understood everything
DAMN bro!! Great Explanation, keep doing this great work!!
Thanks a lot for the video....clear and awesome explanation.....keep making such videos They are really helpful
I never thought it is as simple as this
@techdose4u
3 жыл бұрын
Nice :)
Best explanation ever. I usually don't comment on videos, but this is the best!
@techdose4u
3 жыл бұрын
Thanks for letting me know :)
awessome expalnation bro, pura ssamjg aagaya
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 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
@techdose4u
3 жыл бұрын
Right 👍🏼
@Jitendrakumar-gb7cn
2 жыл бұрын
after each printing check the while condition again that you are incrementing for eg after top++ check whether top
@ashish-bisht
2 жыл бұрын
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
Beautifully explained and clean code
Thank u , you explained the problem very well, i was struggling to understand the solution before watching your video
Amazing, the trick made the problem very easy
Your all video tutorials are awesome !!
@techdose4u
4 жыл бұрын
Thanks :)
It helps me to explore the new way of solving the problem..
You are a freaking genius!!
this is a really good trick , thanks for explaining it to so clearly
Nice! Thanks for sharing!
Thanks Bro. You made this question really easy. I was really frustrated. Thanks for the help.
@techdose4u
3 жыл бұрын
Welcome :)
Excellent explanation thanks for this.
Very much intutive and amazing approach
thanks u so much man, for such a nice and easy explaination :)
Woah.. what an explanation.. 🔥 amazing ❤️
Awesome Explanation Sir
really helpful! THANKYOU
Soo good ! Legends always make it look soo easy !
@techdose4u
3 жыл бұрын
Thanks 😅
Very good description. Thank you.
I've worked for 5 hrs and wasnt able to solve this your approach is great and i sloved it with ease. THANK YOU!!!!!
@techdose4u
3 жыл бұрын
Welcome :)
Amazing explanation!
Explained well. Thanks.
So beautifully explained
just awsome made my code just after first 3 min of viedo .
Great explanation. Thanks a lot!!
Great explanation...! Thank you!
Absolute Explaination BUDDY :}
Bro ur way of explaining it with 0,1,2,3 direction solved my every doubt of this question.
@techdose4u
Жыл бұрын
Nice 😊
thanks for the explanation.its helpful
Thanks sir . Love your work . Salute from Punjab !!
@techdose4u
3 жыл бұрын
Thanks paji :)
You explained in such a beautiful manner thank you...!!!
@techdose4u
2 жыл бұрын
Welcome :)
This is the best channel for any explainationof code thankyou so much
@techdose4u
3 жыл бұрын
Welcome :)
excellent explaination!
VERY HELPFUL!!!!!!
Now I've solved this problem. Thank you
Great explanation. Looking forward to more videos and Data Structure series 🙌
@techdose4u
4 жыл бұрын
Sure :)
Amazing Explanation
Great Explanation, Thank you !!!
@techdose4u
3 жыл бұрын
Welcome :)
super bro 😍 great explaination
Amazing explanation! Thank you!
@techdose4u
3 жыл бұрын
Welcome
Awesome explanation
very nice explanation keep it up bro
so simple explanation for a tricky question like this
Amazing explanation I got the approach will code it myself ,to get a grasp
@techdose4u
3 жыл бұрын
Great
Depicted the approach very well. Thanks :)
@techdose4u
3 жыл бұрын
Welcome :)
Awesome solution!!! Great explanation.
@techdose4u
4 жыл бұрын
Thanks :)
amazing!! you make me like algorithms
Awesome video.
i have easily understand great explanation😍😍😍😍😍
Thanks a lot for this.
Hey superb video and really helpful , can you please do a video on "Matrix Rotation" , that would help a lot.
Amazing explaination
Was able to solve all the variations of spiral matrix in Leetcode after watching this video
That awesomelyyyyy greattttttt :)))) thanks
really nice brother ! this is one of the best class that I have ever seen.
@techdose4u
3 жыл бұрын
Thanks :)
Thanks Bro solved from your help
best explanation in whole youtube
Great Explanation
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.
@techdose4u
3 жыл бұрын
Nice :)
@natashaganjoo4464
2 жыл бұрын
which company's interview btw?
amazing explanation