Jump game | Leetcode #55 | Valley peak approach

Sdílet
Vložit
  • čas přidán 24. 04. 2020
  • This video explains a very important programming interview problem which is to find if it is possible to jump indices of an array and reach the last index of array or not. We have some given constraints which are, we can't jump from 0 valued index and that we always start at index 0. I have shown the solution using backtracking intuition and a very beautiful observation using valley peak approach. I have taken easily comprehend-able examples and finally explained the code for the same. As usual, CODE LINK is given in the description below. If you find any difficulty or have any query then do COMMENT below. This problem is from Day 25 of the leetcode 30 days April coding challenge. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
    CODE LINK: gist.github.com/SuryaPratapK/...

Komentáře • 304

  • @techdose4u
    @techdose4u  Před 9 měsíci

    🟣 JOIN our 𝐋𝐈𝐕𝐄 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐭𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐩𝐫𝐨𝐠𝐫𝐚𝐦 through whatsapp query: +91 8918633037
    🔴 𝐂𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐚𝐥𝐥 𝐨𝐮𝐫 𝐂𝐨𝐮𝐫𝐬𝐞𝐬: techdose.co.in/

  • @preetibatra208
    @preetibatra208 Před 4 lety +248

    To the world you may be just youtuber , but for us(learning geeks ";) you are the hero!! great work...

    • @techdose4u
      @techdose4u  Před 4 lety +16

      Thanks for your appreciation 😅

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

      🙌🏻🙌🏻

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

      I thought you would say *To the world you may be just youtuber , but for us(learning geeks ";) you are our world!* xDDD

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

    I could not appreciate you more for your initiative of making video each day. BIG THANKS.

  • @gurpreetchawla2066
    @gurpreetchawla2066 Před 3 lety +12

    Whenever i am not getting clear Explaination of a problem in other channel , i jump to this channel and you solves it in such a way that anyone can understand comfortably .
    You got the way of "How to Teach so that anyone can understands".

  • @pushkarkumarkanikicherla8812

    I just love the way you explain, even a novice programmer can understand the concept. Keep going.

  • @sajithtm4864
    @sajithtm4864 Před rokem

    Great explanation. Glad to see you posting more videos on DS.

  • @ovipoddar2723
    @ovipoddar2723 Před 4 lety +6

    You are an amazing teacher sir! Your all the explanations are beautiful and clears every concept! Words cannot describe your hard work!

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

    You are great man. Such simplification really helps a lot sometimes.

  • @varunsadhu9060
    @varunsadhu9060 Před 4 lety +11

    Dude, I made the mistake to look for a solution for this from other videos. But i must say i could only understand it by your explanation. Keep up the good work buddy.

  • @rishabhpathak9916
    @rishabhpathak9916 Před 4 lety +11

    What an amazing teacher you are! Thanks a ton!!

  • @soumitadalal6130
    @soumitadalal6130 Před 4 lety +4

    The concepts you teach are so useful that I am bound to adore your vedios.. Keep teaching us like this.. And thanks a lot man..

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

    Few more subscribers away from 10k!
    Congratulations in advance!🤘🙌
    This is just the beginning 💪😎

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

    this lecture note is one of the masterpiece

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

    So cool explaination!
    Impressed 🙌

  • @6priyanshu
    @6priyanshu Před 2 lety

    very well explained...please keep uploading more such video's.....such explanation makes coding easier and interesting..thankyouuuuuuuuu

  • @fullysimplified7139
    @fullysimplified7139 Před 2 lety

    I can never thanks you enough as thanks is such a small word
    I wish you all the best in your future journey

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

    you are the perfect engineer(also visualize physics) and nailed the intuitions of the approach !!!!!!!!!!!!awesome

  • @PersistentProgrammer
    @PersistentProgrammer Před 4 lety +4

    Great explanation. I solved the same question today. I have linked your video in my description.

  • @syamprasadupputalla8233
    @syamprasadupputalla8233 Před 10 měsíci +3

    Bro, trust me this is some serious content. So far, I have been solving problems with a different mindset and you blew me up. I have seen a lot of videos on Leetcode solutions, but never seen something like this, and explanation is very clear. Thank you so much brother :)

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

    What an Explanation. Give a big round of Applause to this sir...

  • @bookswithpriya
    @bookswithpriya Před 2 lety

    Crystal clear explanation.. Thank you 🙌

  • @ersinerdem7285
    @ersinerdem7285 Před 2 lety

    wow, just wow! only thing I could add would be, exiting early after the reachable calculation by checking if you can reach the end.

  • @unlockingitpotential575

    Your explanation understood KG level student ,that's a great work

  • @AnantSanatanGyan
    @AnantSanatanGyan Před dnem

    this solution is just a master peace and you the master 🙌

  • @willturner3440
    @willturner3440 Před 3 lety

    You again proof you are great, love u bro

  • @downshots
    @downshots Před 3 měsíci

    that was a great explanation i even dont need to see the whole video for getting the idea

  • @AdarshSingh-vt4kw
    @AdarshSingh-vt4kw Před 2 lety +4

    It would be much better if you also tell about the minimum number of steps required to move to at the end of the array

  • @saket9363
    @saket9363 Před 4 lety +4

    Thank you so much for all your videos! I am learning a lot!
    Just one quick suggestion!
    Can you please show the actual Leetcode question at the start of the video? It would be really helpful! Thanks once again!

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

      Actually the questions are easy to understand with lower constraints. So it would be very easy to understand. I read the questions first if it has more constraints.It saves TIME in video length 😅

  • @scarywitcher
    @scarywitcher Před rokem +1

    finally understood brother. thanks to you

  • @simmi641
    @simmi641 Před 5 měsíci

    To the point explanation thank you ❤

  • @alex-gz7ud
    @alex-gz7ud Před 3 lety +1

    Awesome explanation!!!! You saved my day!!!

  • @Utkarshgg
    @Utkarshgg Před rokem

    reachable

  • @elasingh3151
    @elasingh3151 Před 2 lety +2

    Great explanation! Please create more videos on leetcode problems.

  • @indrajith2002
    @indrajith2002 Před 9 měsíci

    bro you really explain with clarity just love it .Keep going

  • @navinshyamkuwar9401
    @navinshyamkuwar9401 Před 3 měsíci

    Very Good Explanation.

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

    Precisely explained!! Thanks!

  • @shridivyasharma5536
    @shridivyasharma5536 Před 2 lety

    Very nice and neat explanation!

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

    Great explanation! Thank you!

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

    unique explanation ! Thank you sir

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

    sir your explanation is awesome it becomes so easy to understand❤️👍

  • @blitzkrieg5454
    @blitzkrieg5454 Před 2 lety

    Brilliant explanation!

  • @rajendertanwar1881
    @rajendertanwar1881 Před měsícem

    This explanation truly deserves ❤ 👍

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

    awesome, thanks for this great lesson

  • @skmixvlogs
    @skmixvlogs Před 4 lety

    Great Explanation!!!

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

    Amazing Explanation
    Thanks bhaiya

  • @ganeshkamath89
    @ganeshkamath89 Před 2 lety +2

    Perhaps you can break the loop if the value of reachable reaches the last index, like this. Because, if at least one value reached last index then it is possible to reach the end.
    if (reachable >= n - 1)
    break;

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

    My coding skills improved a lot sir because of you❤

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

      Keep in coding and you will improve further :)

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

    Bro your every video has very good explanation.It is easy to understand

  • @user-of7cs9vs8i
    @user-of7cs9vs8i Před 3 měsíci

    its very easy and cool explanantion

  • @hinata4661
    @hinata4661 Před 4 lety

    please upload the min jumps problem using dynamic programming. If already uploaded please share the link

  • @charanpasupula3763
    @charanpasupula3763 Před 2 lety

    After for loop I think we still need to have another if condition to check if reachable >= array.length - 1
    otherwise this code is failing for the case of [1,0,1], do correct me if m wrong
    edit: I was wrong in writing this condition in for loop i < array.length - 1 , it should be i < array.length

  • @greyhat6599
    @greyhat6599 Před rokem

    Great explaination Sir !
    💝🔥

  • @sagarksahoo4667
    @sagarksahoo4667 Před 2 lety +2

    explanation was very crystal clear, good work

  • @creatorstudio5945
    @creatorstudio5945 Před 11 měsíci

    Amazing explanation sir :))

  • @pritishpattnaik4674
    @pritishpattnaik4674 Před 2 lety

    Very much well explained

  • @rbk.technology4747
    @rbk.technology4747 Před rokem

    Really amazing

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

    I wish I have your brain man, I wasn't able to think this kind of solution... you earn a new subscriber

    • @techdose4u
      @techdose4u  Před 4 lety

      Thanks :) You will also be good in some time if you keep practicing.

  • @RandomShowerThoughts
    @RandomShowerThoughts Před rokem

    great explanation

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

    Nice explanation sir...thanks for the video

  • @JaideepKumarSingh14
    @JaideepKumarSingh14 Před 2 lety

    Great explaination

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

    Dude... just an awesome explanation.

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

    good explaination..totally understood the problem and its solution.

  • @zeinebkarma5038
    @zeinebkarma5038 Před rokem

    Thank you!

  • @yaswanthp2294
    @yaswanthp2294 Před rokem

    Again excellent explanation

  • @tejaschougale5669
    @tejaschougale5669 Před 9 měsíci

    Nice Explanation

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

    I have no words to say ..lovely excellent video

  • @marq_8976
    @marq_8976 Před 4 měsíci +1

    This is the solution that I can understand.

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

    that's the best video on this topic ,sir plz upload some dynamic programming video

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

    Sir you are our savior and motivation 🙏

  • @shridharsarraf2188
    @shridharsarraf2188 Před 11 měsíci

    Surya pratap sir, jab bhi leetcode se frustrate ho jata hun aapke videos dekhta hun. Aap itna calmly koi bhi problem batate ho aur that also calms me down. Lekin kya karun sir dp hai bhi aisa topic ki itni practice ke baad bhi basic medium questions bhi rula dete hain

  • @575saisri4
    @575saisri4 Před 4 lety +2

    sir, u r really the best.. thank u so muchhhh..

  • @myvinbarboza3038
    @myvinbarboza3038 Před rokem

    So intutive love it

  • @AMITKUMAR-nw5ns
    @AMITKUMAR-nw5ns Před 2 lety

    thank you sir, amazing.

  • @RaviYadav-xg2hy
    @RaviYadav-xg2hy Před 4 lety +3

    we can also start from ending index of the array and keep updating the required jumps(starting from 1), and finally check for the first element if it has the required number of jumps !!

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

      Yes correct. Both ways are same only.

  • @mr.naresh3004
    @mr.naresh3004 Před 2 lety +1

    omg nice presentation to give us the logical intuition thankyou....

  • @arindamjain6892
    @arindamjain6892 Před 2 lety

    Thanks man!

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

    what will be time complexity of dp solution??

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

    Nice Explanation! Have you also uploaded a video of Jump game II(minimum jumps to reach end)?

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

      Not yet. I will make it once I start dynamic programming.

  • @vibhasyadav6491
    @vibhasyadav6491 Před 2 lety

    @TECH DOSE please make a video on minimum jumps to reach the end.

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

    Wow, what a nice solution...thanks

  • @codingwithneeraj1305
    @codingwithneeraj1305 Před 2 lety

    exceptional approach have you thought of this approach on your own??

  • @indian3412
    @indian3412 Před 10 měsíci

    hey,
    How do you develop such thinking and procedure to solve such problem.
    Could you guide me how i can solve such tricky questions

  • @rajbhushan3541
    @rajbhushan3541 Před 9 měsíci

    good explanantion

  • @beinghappy9223
    @beinghappy9223 Před rokem

    Thanks really helpful

  • @vinaykumardahiya4260
    @vinaykumardahiya4260 Před 4 lety

    You might just be the best!

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

    Loved it!

  • @navyasri5077
    @navyasri5077 Před 2 lety

    thankyou so much

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

    How do we derive such methods on the spot. I tried this with recursion. Got TLE. Then tried maintaining a list which tells me what index I have already reached out to in previous recursion step to skip it. Then also TLE. And then here it is. Done in O(n). How to achieve this sort of critical thinking. You are awesome.

  • @azizurrahman0375
    @azizurrahman0375 Před 2 lety

    Sir, Why did you use pre-increment in for loop?

  • @letsdoeverythinginoneweek9398

    how can we find max jumps to reach at end of array

  • @rhinoara7119
    @rhinoara7119 Před 2 lety +2

    Another good approach with O(1) complexity will be start searching for 0 from ending of the array, when a zero is found check next number is greater than 1,if not check if its next greater than 2. Return false if this condition fails until index 0

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

    Thanks sir. Great explanation.

  • @AKASHSINGH-td7wx
    @AKASHSINGH-td7wx Před 2 lety

    can you please give me the code of that backtracking approach u mention at the beginning...?

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

    thankuu sir you made this very easy 😃😃

  • @kamvatamia4146
    @kamvatamia4146 Před 4 lety

    I like this video.

  • @sugandhm2666
    @sugandhm2666 Před 3 lety

    Too good

  • @stonecoldcold2941
    @stonecoldcold2941 Před 4 lety +2

    Really a great explanation

  • @RohitThakur-oe6ws
    @RohitThakur-oe6ws Před 3 lety +1

    Thankyou for easy explaination

  • @vivek.tiwary
    @vivek.tiwary Před 2 lety

    How many problems you solved to get the depth of this kind of problem? No one explained like you did. Thank you

  • @avishekarora
    @avishekarora Před 2 lety

    That's a really god solution