Spiral Traversal - Solution | 2-D Arrays | Data Structure and Algorithms in JAVA

Sdílet
Vložit
  • čas přidán 19. 07. 2020
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we discuss the solution where we are required to traverse spirally in a 2d array and display the elements of the 2d array in the same manner. For a better understanding of the problem, click here: • Spiral Traversal - Que...
    For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
    #pepcoding #programming #freeonlinecourses
    Have a look at our result: www.pepcoding.com/placements
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education

Komentáře • 163

  • @lokeshnegi5051
    @lokeshnegi5051 Před 3 lety +63

    before watching this video i was thinking the problem is so tough,but sir your explanation really changed my mind.

  • @nishantsharma8776
    @nishantsharma8776 Před 4 lety +43

    mene pure youtube par aisa koi tutor nahi dekha you are extraordinary.and you deserve more Subscribers.mughe to ye samagh nahi aa RHA log etna accha channel leave krke or channels ko 100-100K subscriber kaise de dete hai

    • @Pepcoding
      @Pepcoding  Před 4 lety +22

      bhai linkedin/fb pe ek post likh do, ya college mei webinar kra do. Viewers ko pta chal jaega. Sabka bhla hoga. Hmara bhi, bacho ka bhi

    • @shivendrapathak8480
      @shivendrapathak8480 Před 3 lety +4

      @@Pepcoding you are an extraordinary teacher and you are doing so much effort to prepare us from zero to pro level.I'm referring to all my friends to join this channel.
      Thankyou! so much sir.

    • @56_ashishsingh91
      @56_ashishsingh91 Před 3 lety +2

      @@Pepcoding I'll surely write about your channel on Quora and LinkedIn. You're one of the finest teacher I ever saw. Kaash, aapke channel k baare m pehle pata hota. Now, I'm in 6th sem, still have one year left. Learning from you everyday, sir.

    • @abhishekanand5898
      @abhishekanand5898 Před 3 lety +2

      @@56_ashishsingh91 It is never too late bhaiii...jb start ki tab accha...pelo accha se..

  • @DevilaBakrania
    @DevilaBakrania Před 3 lety +27

    Blown away by the explanation!! Hats Off you made it super smooth + I remembered the logic right away ! This is my first video of Pepcoding.. You made it so easy.

  • @democrats9579
    @democrats9579 Před 2 lety +5

    What an Explanation! This is amazing. Thank You!

  • @thesurajpatade
    @thesurajpatade Před 2 lety

    Amazing explanation, planning to binge watch all problems!!

  • @tubakhalid5222
    @tubakhalid5222 Před 2 lety +1

    You are one of a kind sir ! Gonna enroll in your course very soon !!!!

  • @rohitmadaan6679
    @rohitmadaan6679 Před 2 lety +1

    I tried this question in which spiral starting from left... my code passed in all test cases... thanks for the wonderful explanation ... now i'm perfect in this question. thanks alot

  • @CSBDPSAHITHIRANI
    @CSBDPSAHITHIRANI Před 3 lety +3

    You make any difficult problem very very simple. Thank you so much!!

    • @Pepcoding
      @Pepcoding  Před 3 lety +3

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      czcams.com/users/Pepcodingabout?view_as=subscriber

  • @venom3380
    @venom3380 Před rokem

    Thankyou for the videos Sir! hoping to complete most of it by the end of 2022😄

  • @afzalriz449
    @afzalriz449 Před rokem

    most underrated channel. Great Explanation. 👏

  • @yogeshpandey730
    @yogeshpandey730 Před 2 lety

    very well explained, i can't find such an easy explanation over internet . Thank you Sumeet sir.

  • @vishalpuri9360
    @vishalpuri9360 Před 3 lety +4

    haven't seen a teacher like you before
    i wish i could meet you in my life ; you are legend sumeet sir. My coding skills are improving day by day nd it is just because of you sir. you are really a god for me sir you are the best teacher. lots of respect and love from my side sir.

    • @rayedsafdar3684
      @rayedsafdar3684 Před 2 lety +1

      Just keep practicing and you'll meet him when he'll take ur interview

  • @faizanhaider3953
    @faizanhaider3953 Před rokem

    Sir aapne jo smjhaya h naaa... Kasam se maza aagaya... Bahut jbr10

  • @satyaganesh672
    @satyaganesh672 Před 2 lety

    bro ur a saviour.. ur explanations are god level explanations

  • @mohsinimam2048
    @mohsinimam2048 Před 2 lety

    Thank for such an easy explanation!

  • @sayantansadhu6380
    @sayantansadhu6380 Před 2 lety

    Extremely beautiful and simple explanation ❤️

  • @abhishekvishwakarma9045

    awesome explanation sir, I will never forget this logic

  • @amangupta4914
    @amangupta4914 Před rokem

    Visiting first time but i must say i m totally impressed...such a smooth teaching

  • @24381498
    @24381498 Před 3 lety

    Amazing explanation Sumeet sir. Thanks

  • @shreyanshjamuar8921
    @shreyanshjamuar8921 Před 3 lety

    Bro maza aa gya yaar,you r awesome sir.

  • @asan9657
    @asan9657 Před 2 lety +1

    Maza Agaya sir
    I wish I could study the complete syllabus of DSA from you👌

  • @abhinavvgoyall
    @abhinavvgoyall Před rokem

    Made it so simple. thank you!

  • @codelite700
    @codelite700 Před rokem

    Sir made the while loop terminating condition so damn simple & cool.

  • @mohammedabdulaziz4400

    Kya baat hai sir, kyaabbaat hai sir!!. Yeh baat hai sir!

  • @akshayagrawal2222
    @akshayagrawal2222 Před 2 lety

    Sumit bhai you are great...kitna simple explaination

  • @yogeshmusale1188
    @yogeshmusale1188 Před rokem

    Thank you for teaching this program.🙏🙏

  • @piyush_sh98
    @piyush_sh98 Před rokem

    Most underrated channel for coding 🙌

  • @BronsonMendonca
    @BronsonMendonca Před 2 lety +1

    Thank you for this super simple explanation!!

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Glad it was helpful! for better experience and well organised content sign up on nados.io and start learning.

  • @rounakjoshi6680
    @rounakjoshi6680 Před 2 lety

    Loved the way to teach🙏

  • @rohitmadaan6679
    @rohitmadaan6679 Před 2 lety

    Great explanation, Subscribed❤

  • @manthanvijaywargia2041

    Thanks a ton for the best explanation sir
    🙏🙏🙏🙏🙏🙏

  • @kritikasharma3331
    @kritikasharma3331 Před 2 lety

    Best teacher in the world !!! I'm amazed by the explanation.

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Glad you loved it! For better experience and well organised content sign up on nados.io and start learning.

  • @tanmaythaker2905
    @tanmaythaker2905 Před 3 lety +3

    What an explanation! Loved it!

  • @sanyasareen393
    @sanyasareen393 Před 3 lety +1

    Sir, Aapne bohot achhe se explain kiya hai solution. Sab samjh aa gya thank you

  • @nandankakadiya1494
    @nandankakadiya1494 Před 2 lety

    Simply amazing 🔥

  • @iffyaiyan8942
    @iffyaiyan8942 Před 3 lety +1

    Thanks for this video Sir, it cleared all doubts related to this type of problem

  • @nipunsharma2670
    @nipunsharma2670 Před 2 lety

    very nice explanation .Thanku sir!!

  • @ishanshah3309
    @ishanshah3309 Před 2 lety +1

    This is seriously good explanation. I mean his explanation made this leetcode medium problem look like a very easy problem.

  • @deepanshusaxena7471
    @deepanshusaxena7471 Před rokem

    Great explaination.

  • @anandkumar-ko5ok
    @anandkumar-ko5ok Před 2 lety

    great work pepcoding

  • @satadrumondal8671
    @satadrumondal8671 Před 3 lety +1

    Sir great video 👌.Sir I request you to put more program on array and recrusion.

  • @shashankchaturvedi7876

    best teacher on you tube

  • @shivamverma-mt6kp
    @shivamverma-mt6kp Před rokem

    Thanks a lot, Sir

  • @Satishkumar-rx7oy
    @Satishkumar-rx7oy Před 2 lety

    this video is really helpful, thanks for making this

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Glad it was helpful!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @puneetgupta2060
    @puneetgupta2060 Před 3 lety

    Apke tutorial bahut ache hai sir thanks for making the vedio

    • @Pepcoding
      @Pepcoding  Před 3 lety

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like my efforts, I request a review
      g.page/Pepcoding/review?rc

  • @sakshiaggarwal6199
    @sakshiaggarwal6199 Před 3 lety +1

    Thank you so much sir!! You're amazing

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Keep supporting and keep loving Pepcoding😊

  • @acciocoder6596
    @acciocoder6596 Před 2 lety +1

    Awesome sir...really loves alot ur way of explaining

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Thanks a ton. For better experience visit on nados.pepcoding.com
      Also follow our Instagram account to stay updated.
      instagram.com/pepcoding/

  • @vipulkumar3752
    @vipulkumar3752 Před 2 lety

    very helpful thank you sir

  • @deepanshum5967
    @deepanshum5967 Před 2 lety

    Thankyou so much sir

  • @sharikkumar8581
    @sharikkumar8581 Před 3 lety

    Bahut khubsurat explanation sir....thank you :)

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @neelshah4812
    @neelshah4812 Před 3 lety +1

    sir, you make the explanation very interesting nd addictive..maza aagya

  • @namanmalhotra6386
    @namanmalhotra6386 Před 4 lety +1

    sir you are doing a great job.Thankyou sir.

  • @saneetkaul8150
    @saneetkaul8150 Před 2 lety

    Thank you

  • @akshyananda7219
    @akshyananda7219 Před 3 lety

    Awesome explanation. Thank you sir

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      Glad to know that you liked the content. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem. If you like our efforts, will you like to write a review about us here - g.page/Pepcoding/review?rc

  • @bite027_ketansharma6
    @bite027_ketansharma6 Před 2 lety

    maza aa gya!

  • @akshivmittal1188
    @akshivmittal1188 Před 6 měsíci

    mazza aa gya

  • @PROTECHRAHUL
    @PROTECHRAHUL Před 2 lety +1

    Easiest explanation ever😎

  • @shashwatkrishnashukla2284

    SIR you are OP,pls make a video on spiral traversal of 3D matrix too

  • @azeemali6865
    @azeemali6865 Před 2 lety

    the best explanation ever...

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @harshadashinde1796
    @harshadashinde1796 Před 2 lety

    thanks for this sir..

  • @codebits2120
    @codebits2120 Před 3 lety

    Will it work ?if we write in the condition of while loop like : while(int k

  • @justaRidhaMthinGs
    @justaRidhaMthinGs Před rokem

    rather than write count and total elements just write "if(maxr < minr ) return; " after the loop of bottom wall

  • @hinamankani5319
    @hinamankani5319 Před 3 lety +1

    Wow i m so glad,i did this question on my own😊😊

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      Yay!! I am glad too. Keep learning

  • @neelshah4812
    @neelshah4812 Před 3 lety +2

    sir
    i think it should be (cnt

  • @pYthonroasT
    @pYthonroasT Před 2 lety

    thanks

  • @shivanshm1
    @shivanshm1 Před 3 lety

    ur best bro....such an intersting lecture...

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Thanks a ton. thanks for motivation

  • @honey.hemant_
    @honey.hemant_ Před rokem

    Can i use while(minc

  • @geetanegi2736
    @geetanegi2736 Před 3 lety +1

    🔥🔥mza agya. Jai ho sir ki.

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      thank you for motivation beta

  • @simardeepkaur8275
    @simardeepkaur8275 Před 2 lety

    awesome

  • @sarthaknikhal5540
    @sarthaknikhal5540 Před 3 lety

    SIr, what do you mean by, "dry run karke dekho."?

  • @arvindg553
    @arvindg553 Před 2 lety

    U r awesome awesome awesome sir

  • @arvindg553
    @arvindg553 Před 2 lety

    Best on youtube

  • @sandipdeb5859
    @sandipdeb5859 Před 2 lety

    Thank you so much sir ❤

    • @Pepcoding
      @Pepcoding  Před 2 lety +1

      Glad it helped!
      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

  • @adityaverma8463
    @adityaverma8463 Před 2 lety

    Sir Max column ko array[0]. length kyu liye ?

  • @abhisheksoti1115
    @abhisheksoti1115 Před 2 lety

    Hello Sir, Big Fan, great explanation... but there is one small improvement that I could think of...instead of checking cnt < tne inside the for loop condition, if we could add
    if(cnt == tne){
    break;
    }
    between left and bottom, bottom and right, right and top, there would be a few less condition checks in total.
    I have started practicing on NADOS, great platform Sir. Thank you so much.

    • @Pepcoding
      @Pepcoding  Před 2 lety

      For better experience and well-arranged content
      visit- nados.pepcoding.com
      Also you can post your query on community tab.
      Don't forget to follow us on Instagram
      instagram.com/pepcoding/

  • @kamalkumar7133
    @kamalkumar7133 Před 2 lety

    smoooooooth 💕

  • @rishabhtripathi6465
    @rishabhtripathi6465 Před 4 lety

    Very good explanation.

  • @harshchaudhary8182
    @harshchaudhary8182 Před 3 lety

    best tutorial.

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Thankyou beta!
      Keep learning and keep supporting Pepcoding😊

  • @AnkitKumar-fj8ex
    @AnkitKumar-fj8ex Před 3 lety

    sir you are just awesome

    • @Pepcoding
      @Pepcoding  Před 3 lety +2

      Thankyou beta!
      I am glad you liked it. I hope that you are watching till the end and trying to understand what, how, and especially why of the problem.
      If you like our efforts, will you like to write a few words about us here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

    • @AnkitKumar-fj8ex
      @AnkitKumar-fj8ex Před 3 lety

      @@Pepcoding sure sir

  • @ANUJGUPTA-pc7tf
    @ANUJGUPTA-pc7tf Před rokem

    Sir what about the structure...?
    What if we want to maintain the structure of matrix after spiral...!

  • @santanukumar5714
    @santanukumar5714 Před 3 lety

    at 5:17 can u explain why u take j< arr[0].length instead of arr.lenghth

    • @santanukumar5714
      @santanukumar5714 Před 3 lety

      @@nikhilflautist ya sir i understand it
      And thank u for giving time to clear my doubt👍.

  • @amannegi8256
    @amannegi8256 Před 3 lety +2

    G.O.A.T

  • @vedantgolash6084
    @vedantgolash6084 Před 3 lety

    very nice explanation sir

  • @user-Abhi_7544pandey
    @user-Abhi_7544pandey Před rokem

    sir n = 0 m = 0 put krne pe out of bound aa rha hai

  • @jayantaghosh5259
    @jayantaghosh5259 Před 3 lety +1

    Thank you sir🥺🥺

    • @Pepcoding
      @Pepcoding  Před 3 lety

      You are welcome and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

    • @kamalnayan5331
      @kamalnayan5331 Před 2 lety

      @@Pepcoding Upvoted sir.

  • @Iamnoone56
    @Iamnoone56 Před 3 lety +1

    shandaar jabardast zindabaad sir..aaj tulsidas hote to DSAcharitramanas likhte apko idol mnake ;P

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Haha...thankyou😋
      If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @anshutomar304
    @anshutomar304 Před 2 lety

    sir after running it an error occurs shows that there is an "not a statement" error in loops . what to do to fix it.

    • @Pepcoding
      @Pepcoding  Před 2 lety

      For better experience and precisely organised content visit - naods.pepcoding.com
      Also you can post such query on community tab.
      Don't forget to follow us on Instagram
      instagram.com/pepcoding/

  • @crucialkali8983
    @crucialkali8983 Před 3 lety

    nice video dear ,and can you make video playlist on data structure in java:)

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      yahan hai playlist
      www.pepcoding.com/resources/online-java-foundation

  • @bikashbhowal9657
    @bikashbhowal9657 Před 3 lety

    Great

    • @Pepcoding
      @Pepcoding  Před 3 lety

      keep motivating, keep learning and keep loving Pepcoding😊

  • @ArnabJhaYT
    @ArnabJhaYT Před 2 lety

    Best explanation ever 😁😁😁

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Glad you liked it but for better experience and precisely arranged content.
      visit - nados.pepcoding.com

    • @ArnabJhaYT
      @ArnabJhaYT Před 2 lety

      @@Pepcoding Yes sir, I am currently coding in nados and coming here for video solution

  • @vikaskumarnitrr
    @vikaskumarnitrr Před 2 lety

    Dekho bhai aisa hai
    Nahi koi sumeet sir jaisa hai

  • @anckoor
    @anckoor Před 2 lety

    nice

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Keep learning.
      And for better experience and well organised content visit nados.pepcoding.com

  • @jeshar7720
    @jeshar7720 Před rokem

    didn't even think of the box approach

  • @ANUJKUMAR-wc9dz
    @ANUJKUMAR-wc9dz Před 3 lety

    Time complexity going to be O(n) ?

    • @ANUJKUMAR-wc9dz
      @ANUJKUMAR-wc9dz Před 3 lety

      @Himanshu Kataria is it based row and columns if is it based on 1d time complexity should be O(n) ?

  • @sahilmehra290
    @sahilmehra290 Před rokem

    count

  • @shaikhadnan7265
    @shaikhadnan7265 Před 3 lety

    niiiiice

    • @Pepcoding
      @Pepcoding  Před 3 lety +1

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      czcams.com/users/Pepcodingabout?view_as=subscriber

  • @pavanrameshghate5416
    @pavanrameshghate5416 Před 2 lety

    Other youtubers: so we do with algorithm
    Bhaiya: hold my pen

  • @ayushgoel9584
    @ayushgoel9584 Před 4 lety

    bhaiya aaj hi poora 2d array upload kar do, aaj toh flow bna hua hai

    • @Pepcoding
      @Pepcoding  Před 4 lety +5

      hanji. aj poora 2d ho jaega. 1d ke bache hue questions ki bhi koshish rahegi

  • @vinayjain7263
    @vinayjain7263 Před 2 lety

    bhai bata raha hai ye chilla isse jyada pyar se to mera math ka teacher padata hai

  • @varunsharma2043
    @varunsharma2043 Před 3 lety

    code shows out of bound exception

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Beta ek bari dubara kr k dekho, kbhi internet issue ki vja se bhi error aa jata h and if the same error still persists, then let me know.

    • @varunsharma2043
      @varunsharma2043 Před 3 lety

      @@Pepcoding sir i have rectified the error. i ki values print kra ke dekh li. Then found out that i had placed minr-- in one place instead of minr++.
      Thankyou Sir.