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

  • @pankajrathi
    @pankajrathi3 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Thanks

  • @PsSarvna
    @PsSarvna3 жыл бұрын

    Yesterday, I got rejected in final round for not solving this problem. That's why I'm here 🙋‍♂️.

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Now you know it :)

  • @rashidixit1168

    @rashidixit1168

    3 жыл бұрын

    Same here bro

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    @@rashidixit1168 :o

  • @titanofchaos

    @titanofchaos

    3 жыл бұрын

    which comapny?

  • @PsSarvna

    @PsSarvna

    3 жыл бұрын

    @@titanofchaos Zoho On-Campus

  • @OscarMartinez-nt6zn
    @OscarMartinez-nt6zn Жыл бұрын

    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!

  • @premsainoolu8290
    @premsainoolu82902 жыл бұрын

    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

  • @doersstuff8067
    @doersstuff80672 жыл бұрын

    before watching this video I couldn't believe that i can understand this approach to this problem. You made it so simple.

  • @JuanGarcia-rq9hz
    @JuanGarcia-rq9hz3 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Thanks :)

  • @anantpatel8342
    @anantpatel83424 жыл бұрын

    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

    @techdose4u

    4 жыл бұрын

    Thanks :)

  • @laharibangaru3756
    @laharibangaru37563 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @mugdhabasak9335
    @mugdhabasak93353 жыл бұрын

    the simplicity of this solution just blew my mind!

  • @akanshamishra6776
    @akanshamishra6776 Жыл бұрын

    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.

  • @jinysong2990
    @jinysong29903 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Nice 😊

  • @lakshaysingla2754

    @lakshaysingla2754

    2 жыл бұрын

    3D spiral ata hai kya aapko?

  • @hhhhhhhhh963

    @hhhhhhhhh963

    2 жыл бұрын

    @@lakshaysingla2754 Mujhe toh 2D he Tough laga

  • @lakshaysingla2754

    @lakshaysingla2754

    2 жыл бұрын

    @@hhhhhhhhh963 yaar wo to hai but hamare college walo ne 3D spiral de diya test mai karne ko

  • @saunaknandi1814

    @saunaknandi1814

    2 жыл бұрын

    @Jiny Song on which platform you run the program

  • @kshitizagarwal8389
    @kshitizagarwal83893 жыл бұрын

    OMG this one is amazing man! Highly appriciated. Got me another way of approaching a problem Thanks. Kudos!

  • @kritikasingh4698
    @kritikasingh46982 жыл бұрын

    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.

  • @mohitpandya_2228
    @mohitpandya_2228 Жыл бұрын

    The best explanation on entire youtube!! Hats off sir! 💜

  • @sugandhm2666
    @sugandhm26662 жыл бұрын

    Bro you teach the approach and logic so well. Many KZreadrs simply jump into coding without explanations

  • @JayJayJay007
    @JayJayJay007 Жыл бұрын

    Brilliant explanation, very easy to understand and remember the approach. Big thanks!

  • @akankshitadutta8842
    @akankshitadutta88422 жыл бұрын

    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!

  • @rajatagrawal1999
    @rajatagrawal19992 жыл бұрын

    The way u have explained the concept is amazing. I coded it without any help. Thanks :)

  • @ARIFAHMAD-cj4xk
    @ARIFAHMAD-cj4xk Жыл бұрын

    Thank you, this is the easiest approach i have seen so far and well explained

  • @techykush7192
    @techykush71923 жыл бұрын

    i really like your teaching style ,mind blowing u understood us in a simplest form i have seen ever thanks bhaiya 😊😊

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome 😃

  • @chandraprabhat3496
    @chandraprabhat34963 жыл бұрын

    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 .

  • @sureshgarine
    @sureshgarine2 жыл бұрын

    wow! what a wonderful explanation. saying thanks is not enough. please continue the good work for the community

  • @techdose4u

    @techdose4u

    2 жыл бұрын

    Thanks

  • @hackytech7494
    @hackytech74944 жыл бұрын

    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

    @techdose4u

    4 жыл бұрын

    Welcome :)

  • @divyanshudwivedi3756
    @divyanshudwivedi3756 Жыл бұрын

    You made it look very easy . Thanks a lot !

  • @SenthilKumar-nt2tk
    @SenthilKumar-nt2tk3 жыл бұрын

    U r such an awesome person ..thank you for this code... god bless you

  • @avinash7786
    @avinash77864 жыл бұрын

    Literally you are a great person..What an explanation..Thank you soooo much.

  • @techdose4u

    @techdose4u

    4 жыл бұрын

    Welcome :)

  • @natureone5617
    @natureone56173 жыл бұрын

    what a lovely explanation and a very easy approach to traverse a matrix spirally thank you and loved to watch more videos

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @jisanson
    @jisanson10 ай бұрын

    the best explanation i've found for the problem, thank you!

  • @rahulvarma3004
    @rahulvarma30043 жыл бұрын

    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

  • @sindhubandaru55
    @sindhubandaru553 жыл бұрын

    Thank you for your explanation . After watching this I'm able write the program without copying the code

  • @maheshvenkat1349
    @maheshvenkat13492 жыл бұрын

    Great job in explaining in the reasonable speed and in an very understanding manner! :clap

  • @MsHappygirl26
    @MsHappygirl262 жыл бұрын

    Thank you so much! So easy to understand when you explain it!

  • @techdose4u

    @techdose4u

    2 жыл бұрын

    Welcome :)

  • @preetichib2254
    @preetichib2254 Жыл бұрын

    dhanyawad mitar. helped right on time.

  • @dayanandraut5660
    @dayanandraut56603 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @kingmaker9082
    @kingmaker90822 жыл бұрын

    a huge thanks to you . everything is perfect. you saved my day

  • @mrcgaming9306
    @mrcgaming93062 жыл бұрын

    this is best explanation I have ever seen Thank you so much sir. I understood everything

  • @nightmare_9
    @nightmare_93 жыл бұрын

    DAMN bro!! Great Explanation, keep doing this great work!!

  • @paragroy5359
    @paragroy53592 жыл бұрын

    Thanks a lot for the video....clear and awesome explanation.....keep making such videos They are really helpful

  • @kambalavijay6800
    @kambalavijay68003 жыл бұрын

    I never thought it is as simple as this

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Nice :)

  • @irisi3308
    @irisi33083 жыл бұрын

    Best explanation ever. I usually don't comment on videos, but this is the best!

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Thanks for letting me know :)

  • @aaryansaha9616
    @aaryansaha96162 жыл бұрын

    awessome expalnation bro, pura ssamjg aagaya

  • @tanujmishra2313
    @tanujmishra23133 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Right 👍🏼

  • @Jitendrakumar-gb7cn

    @Jitendrakumar-gb7cn

    2 жыл бұрын

    after each printing check the while condition again that you are incrementing for eg after top++ check whether top

  • @ashish-bisht

    @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

  • @pawanchormule2530
    @pawanchormule2530Ай бұрын

    Beautifully explained and clean code

  • @kianaahmadi193
    @kianaahmadi1932 жыл бұрын

    Thank u , you explained the problem very well, i was struggling to understand the solution before watching your video

  • @anantagarwal863
    @anantagarwal8634 жыл бұрын

    Amazing, the trick made the problem very easy

  • @ShreyaSingh-vr9qi
    @ShreyaSingh-vr9qi4 жыл бұрын

    Your all video tutorials are awesome !!

  • @techdose4u

    @techdose4u

    4 жыл бұрын

    Thanks :)

  • @ritiksrivastava9069
    @ritiksrivastava9069 Жыл бұрын

    It helps me to explore the new way of solving the problem..

  • @dheerajvikas1135
    @dheerajvikas1135 Жыл бұрын

    You are a freaking genius!!

  • @summerray1795
    @summerray17952 жыл бұрын

    this is a really good trick , thanks for explaining it to so clearly

  • @zensic
    @zensic2 жыл бұрын

    Nice! Thanks for sharing!

  • @akki4083
    @akki40833 жыл бұрын

    Thanks Bro. You made this question really easy. I was really frustrated. Thanks for the help.

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @brandoncazares8452
    @brandoncazares8452 Жыл бұрын

    Excellent explanation thanks for this.

  • @pritishpattnaik4674
    @pritishpattnaik46742 жыл бұрын

    Very much intutive and amazing approach

  • @YashSharma-os9ng
    @YashSharma-os9ng Жыл бұрын

    thanks u so much man, for such a nice and easy explaination :)

  • @systemforge
    @systemforge3 жыл бұрын

    Woah.. what an explanation.. 🔥 amazing ❤️

  • @dhirendrakumar4619
    @dhirendrakumar46192 жыл бұрын

    Awesome Explanation Sir

  • @garimachawla775
    @garimachawla7759 ай бұрын

    really helpful! THANKYOU

  • @prajwalpatil9395
    @prajwalpatil93953 жыл бұрын

    Soo good ! Legends always make it look soo easy !

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Thanks 😅

  • @garyclark3483
    @garyclark34832 жыл бұрын

    Very good description. Thank you.

  • @sunnithreddy6031
    @sunnithreddy60313 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @priyanshshah6126
    @priyanshshah6126 Жыл бұрын

    Amazing explanation!

  • @rifathossain2788
    @rifathossain2788 Жыл бұрын

    Explained well. Thanks.

  • @niteenautade
    @niteenautade Жыл бұрын

    So beautifully explained

  • @harshitsahu2704
    @harshitsahu270419 күн бұрын

    just awsome made my code just after first 3 min of viedo .

  • @kirtisachapra9030
    @kirtisachapra9030 Жыл бұрын

    Great explanation. Thanks a lot!!

  • @rakibhasan_
    @rakibhasan_2 жыл бұрын

    Great explanation...! Thank you!

  • @siddharth.chandani
    @siddharth.chandani Жыл бұрын

    Absolute Explaination BUDDY :}

  • @ileshchauhan5483
    @ileshchauhan5483 Жыл бұрын

    Bro ur way of explaining it with 0,1,2,3 direction solved my every doubt of this question.

  • @techdose4u

    @techdose4u

    Жыл бұрын

    Nice 😊

  • @nbdevisree2106
    @nbdevisree21063 жыл бұрын

    thanks for the explanation.its helpful

  • @sehejwahla410
    @sehejwahla4103 жыл бұрын

    Thanks sir . Love your work . Salute from Punjab !!

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Thanks paji :)

  • @shravniwakde1754
    @shravniwakde17542 жыл бұрын

    You explained in such a beautiful manner thank you...!!!

  • @techdose4u

    @techdose4u

    2 жыл бұрын

    Welcome :)

  • @simrankak7045
    @simrankak70453 жыл бұрын

    This is the best channel for any explainationof code thankyou so much

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @mayurkapadnis4265
    @mayurkapadnis42652 жыл бұрын

    excellent explaination!

  • @saurabh122
    @saurabh1223 жыл бұрын

    VERY HELPFUL!!!!!!

  • @RoopaSri-fp7kh
    @RoopaSri-fp7kh3 ай бұрын

    Now I've solved this problem. Thank you

  • @AtulDislay
    @AtulDislay4 жыл бұрын

    Great explanation. Looking forward to more videos and Data Structure series 🙌

  • @techdose4u

    @techdose4u

    4 жыл бұрын

    Sure :)

  • @arslanahmed1311
    @arslanahmed13112 жыл бұрын

    Amazing Explanation

  • @surajmaharana2608
    @surajmaharana26083 жыл бұрын

    Great Explanation, Thank you !!!

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @tejastej8537
    @tejastej8537 Жыл бұрын

    super bro 😍 great explaination

  • @hatemsaadallah8532
    @hatemsaadallah85323 жыл бұрын

    Amazing explanation! Thank you!

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome

  • @InvestmentEducationCommunity
    @InvestmentEducationCommunity Жыл бұрын

    Awesome explanation

  • @lokeshthecodingguy7747
    @lokeshthecodingguy77472 жыл бұрын

    very nice explanation keep it up bro

  • @mayanktiwari3103
    @mayanktiwari3103 Жыл бұрын

    so simple explanation for a tricky question like this

  • @amyanktiwari
    @amyanktiwari3 жыл бұрын

    Amazing explanation I got the approach will code it myself ,to get a grasp

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Great

  • @mansiagrawal4039
    @mansiagrawal40393 жыл бұрын

    Depicted the approach very well. Thanks :)

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Welcome :)

  • @bhavyashah1775
    @bhavyashah17754 жыл бұрын

    Awesome solution!!! Great explanation.

  • @techdose4u

    @techdose4u

    4 жыл бұрын

    Thanks :)

  • @muwnhius
    @muwnhius2 жыл бұрын

    amazing!! you make me like algorithms

  • @prerakparekh4460
    @prerakparekh44603 жыл бұрын

    Awesome video.

  • @user-je9ji4do5z
    @user-je9ji4do5z5 ай бұрын

    i have easily understand great explanation😍😍😍😍😍

  • @mohammadsayem2257
    @mohammadsayem22572 жыл бұрын

    Thanks a lot for this.

  • @tusharkumar1984
    @tusharkumar19843 жыл бұрын

    Hey superb video and really helpful , can you please do a video on "Matrix Rotation" , that would help a lot.

  • @tmiitroorkee1244
    @tmiitroorkee12442 жыл бұрын

    Amazing explaination

  • @pritishpattnaik4674
    @pritishpattnaik46742 жыл бұрын

    Was able to solve all the variations of spiral matrix in Leetcode after watching this video

  • @shivalikagupta3433
    @shivalikagupta34332 жыл бұрын

    That awesomelyyyyy greattttttt :)))) thanks

  • @haribk5995
    @haribk59953 жыл бұрын

    really nice brother ! this is one of the best class that I have ever seen.

  • @techdose4u

    @techdose4u

    3 жыл бұрын

    Thanks :)

  • @MukeshKumar-yx7ck
    @MukeshKumar-yx7ck2 жыл бұрын

    Thanks Bro solved from your help

  • @riyazshaik864
    @riyazshaik8647 ай бұрын

    best explanation in whole youtube

  • @impatientgaming9868
    @impatientgaming98683 ай бұрын

    Great Explanation

  • @subhambanerjee6334
    @subhambanerjee63343 жыл бұрын

    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

    @techdose4u

    3 жыл бұрын

    Nice :)

  • @natashaganjoo4464

    @natashaganjoo4464

    2 жыл бұрын

    which company's interview btw?

  • @prasannapm3220
    @prasannapm32202 жыл бұрын

    amazing explanation