Тёмный
No video :(

Jump game | Leetcode #55 | Valley peak approach 

Techdose
Подписаться 173 тыс.
Просмотров 188 тыс.
50% 1

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.co...

Опубликовано:

 

23 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 305   
@techdose4u
@techdose4u 10 месяцев назад
🟣 JOIN our 𝐋𝐈𝐕𝐄 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐭𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐩𝐫𝐨𝐠𝐫𝐚𝐦 through whatsapp query: +91 8918633037 🔴 𝐂𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐚𝐥𝐥 𝐨𝐮𝐫 𝐂𝐨𝐮𝐫𝐬𝐞𝐬: techdose.co.in/
@preetibatra208
@preetibatra208 4 года назад
To the world you may be just youtuber , but for us(learning geeks ";) you are the hero!! great work...
@techdose4u
@techdose4u 4 года назад
Thanks for your appreciation 😅
@rajatmishra6628
@rajatmishra6628 4 года назад
🙌🏻🙌🏻
@MadForCs16
@MadForCs16 2 года назад
I thought you would say *To the world you may be just youtuber , but for us(learning geeks ";) you are our world!* xDDD
@gurpreetchawla2066
@gurpreetchawla2066 3 года назад
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".
@techdose4u
@techdose4u 3 года назад
❤️
@pushkarkumarkanikicherla8812
@pushkarkumarkanikicherla8812 4 года назад
I just love the way you explain, even a novice programmer can understand the concept. Keep going.
@techdose4u
@techdose4u 4 года назад
Thanks :)
@hydieboyer886
@hydieboyer886 Год назад
1:28
@varunsadhu9060
@varunsadhu9060 4 года назад
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.
@techdose4u
@techdose4u 4 года назад
Thanks bro :)
@algorithmimplementer415
@algorithmimplementer415 4 года назад
I could not appreciate you more for your initiative of making video each day. BIG THANKS.
@syamprasadupputalla8233
@syamprasadupputalla8233 11 месяцев назад
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 :)
@f3-faithfitnessfinance
@f3-faithfitnessfinance 4 года назад
Few more subscribers away from 10k! Congratulations in advance!🤘🙌 This is just the beginning 💪😎
@techdose4u
@techdose4u 4 года назад
Thanks bro :)
@ovipoddar2723
@ovipoddar2723 4 года назад
You are an amazing teacher sir! Your all the explanations are beautiful and clears every concept! Words cannot describe your hard work!
@techdose4u
@techdose4u 4 года назад
Thanks :)
@praveenchouhan6388
@praveenchouhan6388 3 года назад
you are the perfect engineer(also visualize physics) and nailed the intuitions of the approach !!!!!!!!!!!!awesome
@techdose4u
@techdose4u 3 года назад
Thanks 😅
@shashankmehul02
@shashankmehul02 4 года назад
You are great man. Such simplification really helps a lot sometimes.
@techdose4u
@techdose4u 4 года назад
Thanks :)
@rishabhpathak9916
@rishabhpathak9916 4 года назад
What an amazing teacher you are! Thanks a ton!!
@techdose4u
@techdose4u 4 года назад
Thanks bro :)
@PersistentProgrammer
@PersistentProgrammer 4 года назад
Great explanation. I solved the same question today. I have linked your video in my description.
@techdose4u
@techdose4u 4 года назад
Thanks :)
@soumitadalal6130
@soumitadalal6130 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..
@techdose4u
@techdose4u 4 года назад
Welcome :)
@Code_Solver
@Code_Solver 2 года назад
What an Explanation. Give a big round of Applause to this sir...
@saket9363
@saket9363 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 4 года назад
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 😅
@manjunathp9466
@manjunathp9466 3 года назад
Python solution class Solution: def canJump(self, nums: List[int]) -> bool: if 0 not in nums: return True reachable=0 for i in range(len(nums)): if reachable
@techdose4u
@techdose4u 3 года назад
Thanks for sharing 👍 Please keep sharing Codes in Python.
@ladydimitrescu1155
@ladydimitrescu1155 2 года назад
Can you explain the purpose of if 0 not in nums: return True?
@RaviYadav-xg2hy
@RaviYadav-xg2hy 4 года назад
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 4 года назад
Yes correct. Both ways are same only.
@AdarshSingh-vt4kw
@AdarshSingh-vt4kw 2 года назад
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
@unlockingitpotential575
@unlockingitpotential575 Год назад
Your explanation understood KG level student ,that's a great work
@AnantSanatanGyan
@AnantSanatanGyan Месяц назад
this solution is just a master peace and you the master 🙌
@ganeshkamath89
@ganeshkamath89 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;
@downshots
@downshots 4 месяца назад
that was a great explanation i even dont need to see the whole video for getting the idea
@ersinerdem7285
@ersinerdem7285 3 года назад
wow, just wow! only thing I could add would be, exiting early after the reachable calculation by checking if you can reach the end.
@abhijeetbhowmik2264
@abhijeetbhowmik2264 4 года назад
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.
@officialspock
@officialspock 4 года назад
I wish I have your brain man, I wasn't able to think this kind of solution... you earn a new subscriber
@techdose4u
@techdose4u 4 года назад
Thanks :) You will also be good in some time if you keep practicing.
@charanpasupula3763
@charanpasupula3763 3 года назад
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
@MarcoBiedermann
@MarcoBiedermann 4 года назад
You could also loop backwards in order to figure out if the last position is reachable ```ts function canJump(nums: number[]): boolean { const { length } = nums; let lastPos = length - 1; for (let i = length; i >= 0; i -= 1) { if (i + nums[i] >= lastPos) { lastPos = i; } } return lastPos === 0; } ```
@techdose4u
@techdose4u 4 года назад
Yes.....anyone is correct.
@haydnmurray6998
@haydnmurray6998 4 года назад
I see this solution but worst case for both solutions is O(n) so would we count these as the same?
@techdose4u
@techdose4u 4 года назад
Yes true.
@amanbansal97
@amanbansal97 4 года назад
It will take less time to complete because there is no comparison of max
@sajeesyed3384
@sajeesyed3384 2 года назад
this lecture note is one of the masterpiece
@rajendertanwar1881
@rajendertanwar1881 2 месяца назад
This explanation truly deserves ❤ 👍
@techdose4u
@techdose4u 2 месяца назад
Thanks :)
@rhinoara7119
@rhinoara7119 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
@shridharsarraf2188
@shridharsarraf2188 Год назад
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
@elasingh3151
@elasingh3151 2 года назад
Great explanation! Please create more videos on leetcode problems.
@techdose4u
@techdose4u 2 года назад
Sure 😃
@sagarksahoo4667
@sagarksahoo4667 2 года назад
explanation was very crystal clear, good work
@techdose4u
@techdose4u 2 года назад
Thanks :)
@Jyotigupta-vs4mz
@Jyotigupta-vs4mz 20 дней назад
Hello Tech dose sir,Small corrrection in For Loop i should be i
@mystryb345
@mystryb345 4 года назад
Bro your every video has very good explanation.It is easy to understand
@techdose4u
@techdose4u 4 года назад
Thanks
@dhanashreegodase4445
@dhanashreegodase4445 2 года назад
I have no words to say ..lovely excellent video
@techdose4u
@techdose4u 2 года назад
Thanks
@vaibhavgaur8200
@vaibhavgaur8200 3 года назад
JAVA Solution: class Solution { public boolean canJump(int[] nums) { int n = nums.length; int reachable = 0; for(int i=0; i
@techdose4u
@techdose4u 3 года назад
👍🏼
@paragroy5359
@paragroy5359 3 года назад
Nice explanation sir...thanks for the video
@techdose4u
@techdose4u 3 года назад
Welcome :)
@ekengineer9868
@ekengineer9868 2 года назад
So cool explaination! Impressed 🙌
@6priyanshu
@6priyanshu 2 года назад
very well explained...please keep uploading more such video's.....such explanation makes coding easier and interesting..thankyouuuuuuuuu
@prasenjitsingharoy9370
@prasenjitsingharoy9370 3 года назад
Sir you are our savior and motivation 🙏
@techdose4u
@techdose4u 3 года назад
Thanks
@harshpatel1385
@harshpatel1385 4 года назад
My coding skills improved a lot sir because of you❤
@techdose4u
@techdose4u 4 года назад
Keep in coding and you will improve further :)
@marq_8976
@marq_8976 5 месяцев назад
This is the solution that I can understand.
@fullysimplified7139
@fullysimplified7139 3 года назад
I can never thanks you enough as thanks is such a small word I wish you all the best in your future journey
@sajithtm4864
@sajithtm4864 Год назад
Great explanation. Glad to see you posting more videos on DS.
@vivek.tiwary
@vivek.tiwary 2 года назад
How many problems you solved to get the depth of this kind of problem? No one explained like you did. Thank you
@JgNt3981
@JgNt3981 Год назад
How do you get the logic for the problems sir, that too simple one. 😱🙏 please share if you could.
@indian3412
@indian3412 11 месяцев назад
hey, How do you develop such thinking and procedure to solve such problem. Could you guide me how i can solve such tricky questions
@vibhasyadav6491
@vibhasyadav6491 2 года назад
@TECH DOSE please make a video on minimum jumps to reach the end.
@tareqdevdiary
@tareqdevdiary 7 месяцев назад
No explanation can be better than this.
@shubhamkumar-hx1fb
@shubhamkumar-hx1fb 7 месяцев назад
if you think so then you are leaving in some virtual world
@tareqdevdiary
@tareqdevdiary 7 месяцев назад
For me it's the best explanation. I've understood the solution after watching this, before that I watched multiple videos from other youtubers but have found this one the best.@@shubhamkumar-hx1fb
@navinshyamkuwar9401
@navinshyamkuwar9401 4 месяца назад
Very Good Explanation.
@mr.naresh3004
@mr.naresh3004 2 года назад
omg nice presentation to give us the logical intuition thankyou....
@techdose4u
@techdose4u 2 года назад
Welcome 😄
@venkateshthirunagiri85
@venkateshthirunagiri85 4 года назад
We or you are going to Hit 10k subscribers by tomorrow 👏👏👏👏
@techdose4u
@techdose4u 4 года назад
We offcourse. Tommorow I will come LIVE to thank our community for continued support :)
@venkateshthirunagiri85
@venkateshthirunagiri85 4 года назад
@@techdose4u you deserved it 😎
@techdose4u
@techdose4u 4 года назад
Thanks :)
@codingwithneeraj1305
@codingwithneeraj1305 2 года назад
exceptional approach have you thought of this approach on your own??
@Amitkumar-nw5mt
@Amitkumar-nw5mt 3 года назад
still wating for min no of jump to reach the end video 😁😁✌❤
@techdose4u
@techdose4u 3 года назад
👍🏼
@heyrmi
@heyrmi 3 года назад
Great Intuition bhaiya.
@techdose4u
@techdose4u 3 года назад
Thanks Rahul :)
@avinashpatil9662
@avinashpatil9662 3 года назад
good explaination..totally understood the problem and its solution.
@techdose4u
@techdose4u 3 года назад
Nice :)
@willturner3440
@willturner3440 3 года назад
You again proof you are great, love u bro
@nikhilkumar-ot9rn
@nikhilkumar-ot9rn 4 года назад
awesome explanation!!!! can u start a platform where u take questions from us and solve it ...please..
@techdose4u
@techdose4u 4 года назад
It's already ON. I am putting questions which are already requested.
@nikhilkumar-ot9rn
@nikhilkumar-ot9rn 4 года назад
@@techdose4u ok then, could you please solve Educational Codeforces Round 53 (Rated for Div. 2) problem c (vasya and robots) also could you please solve longest palindromic substring using binary search .
@user-of7cs9vs8i
@user-of7cs9vs8i 4 месяца назад
its very easy and cool explanantion
@mikasaackerman2694
@mikasaackerman2694 4 года назад
Nice Explanation! Have you also uploaded a video of Jump game II(minimum jumps to reach end)?
@techdose4u
@techdose4u 4 года назад
Not yet. I will make it once I start dynamic programming.
@reshwanthroyal2601
@reshwanthroyal2601 Год назад
class Solution { public boolean canJump(int[] nums) { int reach = 0; for(int i =0;i=nums.length-1) return true; } // if we cant reach return false; } }
@sandeepnallala48
@sandeepnallala48 3 года назад
Sir for this q dp is not necessary right? I did the q of min jumps to reach end of array , and tried this in similar wau, but getting tle in leetcode, maybe some code mistake.. this simple method is good sir. Sir have you started dp sir?
@kabboghosh1853
@kabboghosh1853 4 года назад
that's the best video on this topic ,sir plz upload some dynamic programming video
@techdose4u
@techdose4u 4 года назад
Sure :)
@kollivenkatamadhukar5059
@kollivenkatamadhukar5059 4 года назад
Can you please guide me on how to approach a problem, I always try to solve a problem but will fail in between and after seeing your explanation after enough trails I feel like this can be done but why I didn't.
@techdose4u
@techdose4u 4 года назад
This requires practice. Don't give up. I was in the same position as you. I struggled and invested a lot of time before I reach to my current position. Even now I face the same problem solving the harder problems but I take the same approach for solving.
@venkateshthirunagiri85
@venkateshthirunagiri85 4 года назад
Make a video on your RU-vid kit like video editors, softwares, Mike u use to make RU-vid videos .......... 🎥🎥
@techdose4u
@techdose4u 4 года назад
Nice idea :)
@tejaschougale5669
@tejaschougale5669 10 месяцев назад
Nice Explanation
@scarywitcher
@scarywitcher Год назад
finally understood brother. thanks to you
@suryakiran2970
@suryakiran2970 Год назад
last approach super
@techdose4u
@techdose4u Год назад
👍🏼
@praphulyadav4471
@praphulyadav4471 3 года назад
sir your explanation is awesome it becomes so easy to understand❤️👍
@techdose4u
@techdose4u 3 года назад
Thanks :)
@emmatime2016
@emmatime2016 3 года назад
Great explanation! Thank you!
@techdose4u
@techdose4u 3 года назад
Welcome :)
@alex-gz7ud
@alex-gz7ud 3 года назад
Awesome explanation!!!! You saved my day!!!
@techdose4u
@techdose4u 3 года назад
Welcome :)
@Utkarshgg
@Utkarshgg Год назад
reachable
@arlynsneha5052
@arlynsneha5052 3 года назад
Thanks a ton!! Can you give the code for calculating the minimum jumps required if we could reach the end..please
@techdose4u
@techdose4u 3 года назад
I will try
@arlynsneha5052
@arlynsneha5052 3 года назад
@@techdose4u thank you🎉
@shantanukumar4081
@shantanukumar4081 2 года назад
Amazing Explanation Thanks bhaiya
@ankitaraj1713
@ankitaraj1713 4 года назад
Precisely explained!! Thanks!
@techdose4u
@techdose4u 4 года назад
Welcome :)
@AKASHSINGH-td7wx
@AKASHSINGH-td7wx 3 года назад
can you please give me the code of that backtracking approach u mention at the beginning...?
@toekneema
@toekneema 3 года назад
Best solution ever
@techdose4u
@techdose4u 3 года назад
Thanks
@abhishekrai4325
@abhishekrai4325 4 года назад
unique explanation ! Thank you sir
@techdose4u
@techdose4u 4 года назад
Welcome :)
@mausami16mau
@mausami16mau 4 года назад
well explained. thanks :)
@techdose4u
@techdose4u 4 года назад
Welcome :)
@indrajith2002
@indrajith2002 10 месяцев назад
bro you really explain with clarity just love it .Keep going
@monishnjs
@monishnjs 3 года назад
Wow, what a nice solution...thanks
@techdose4u
@techdose4u 3 года назад
Welcome :)
@stonecoldcold2941
@stonecoldcold2941 4 года назад
Really a great explanation
@techdose4u
@techdose4u 4 года назад
Thanks :)
@CHIRANJIBNANDY1
@CHIRANJIBNANDY1 4 года назад
Dude... just an awesome explanation.
@techdose4u
@techdose4u 4 года назад
Thanks :)
@bookswithpriya
@bookswithpriya 2 года назад
Crystal clear explanation.. Thank you 🙌
@creatorstudio5945
@creatorstudio5945 Год назад
Amazing explanation sir :))
@RandomShowerThoughts
@RandomShowerThoughts Год назад
great explanation
@rajbhushan3541
@rajbhushan3541 10 месяцев назад
good explanantion
@rbk.technology4747
@rbk.technology4747 Год назад
Really amazing
@hinata4661
@hinata4661 4 года назад
please upload the min jumps problem using dynamic programming. If already uploaded please share the link
@575saisri4
@575saisri4 4 года назад
sir, u r really the best.. thank u so muchhhh..
@techdose4u
@techdose4u 4 года назад
Thanks Sai :)
@vinaykumardahiya4260
@vinaykumardahiya4260 4 года назад
You might just be the best!
@techdose4u
@techdose4u 4 года назад
Thanks
@swatibabbar9953
@swatibabbar9953 3 года назад
How to find minimum jumps to reach end of array with this code?
@rakshith3547
@rakshith3547 3 года назад
Even i had the same question
@arnavkarforma3015
@arnavkarforma3015 3 года назад
We can use this same approach to also get the count of jumps class Solution { public int jump(int[] nums) { if(nums.length == 1) return 0; int res = 0; int currJump =0; int currJumpCopy = currJump; for(int i = 0; i< nums.length-1; i++){ currJump = Math.max(currJump, nums[i]+i); if(i == currJumpCopy){ res++; currJumpCopy = currJump; } } return res; } }
@simmi641
@simmi641 6 месяцев назад
To the point explanation thank you ❤
@monkeytrollhunter
@monkeytrollhunter 3 года назад
I am here after my recursive solution timed out
@AdityaPratapSingh-ss8wg
@AdityaPratapSingh-ss8wg 3 года назад
Same here
@sonumondal9376
@sonumondal9376 Год назад
Yeah becoz it is 2^n so tle
@dimpleshah3037
@dimpleshah3037 3 года назад
Superb explaination....
@techdose4u
@techdose4u 3 года назад
Thanks :)
@swami1016
@swami1016 3 года назад
well explaind
@techdose4u
@techdose4u 3 года назад
Thanks
@divanshmahajan1769
@divanshmahajan1769 3 года назад
what will be time complexity of dp solution??
Далее
Product of array except self | Leetcode #238
15:00
Просмотров 94 тыс.
How I would learn Leetcode if I could start over
18:03
Просмотров 454 тыс.
55. Jump Game || 4 examples to build logic + code
15:30
Remove K digits | Build lowest number | Leetcode #402
15:30
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
LeetCode 55. Jump Game (Algorithm Explained)
10:06
Просмотров 77 тыс.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Просмотров 181 тыс.
How I Got Good at Coding Interviews
6:29
Просмотров 1,6 млн
L5. Jump Game - II | Greedy Algorithm Playlist
16:45
Просмотров 37 тыс.