L4. Jump Game - I | Greedy Algorithm Playlist

  Рет қаралды 60,484

take U forward

take U forward

Күн бұрын

Пікірлер: 66
@ritikkumarsingh5902
@ritikkumarsingh5902 6 ай бұрын
Striver, your DSA Sheet is absolutely phenomenal! It's been an invaluable resource for mastering data structures and algorithms. Looking forward to the remaining topics, especially the much-anticipated sections on strings and heaps. Thanks for all your hard work!
@Professor-du2pf
@Professor-du2pf 5 ай бұрын
After watching the DP Approach this greedy code is far very easy .
@LokeshSharmaCP
@LokeshSharmaCP 5 ай бұрын
i thought about recursion approach but this is really easy and optimal
@shreyxnsh.14
@shreyxnsh.14 Ай бұрын
Good question: class Solution { public: bool canJump(vector& nums) { if(nums.size() == 1) return true; bool zero = false; for(const auto &it : nums){ if(it==0){ zero = true; break; } } if(!zero) return true; int maxIndexReached = 0; for(auto i = 0; i < nums.size(); i++){ if(i > maxIndexReached) return false; maxIndexReached = max(maxIndexReached, (i + nums[i])); if(maxIndexReached >= nums.size()-1) return true; } return true; } };
@GungunSaluja-sy6br
@GungunSaluja-sy6br 5 ай бұрын
waiting for String playlist ❤ and till now all the videos of greedy are osm
@Paradox_1
@Paradox_1 6 ай бұрын
Radhe Radhe bhaiya 💖
@Josuke217
@Josuke217 6 ай бұрын
Waiting for strings ...
@KartikeyTT
@KartikeyTT 4 ай бұрын
do you come to menace and monk streams
@Josuke217
@Josuke217 4 ай бұрын
@@KartikeyTT no
@KartikeyTT
@KartikeyTT 4 ай бұрын
@@Josuke217 okay
@keshavbiyani9202
@keshavbiyani9202 Ай бұрын
Understood striver. Thanks a lot Anyone interested in python code - from typing import List """ Idea is that I need to be able to cross 0 I'll keep checking greedily if the maxIndexReachable is more than current index + val at current index DRY Run 2,3 --> possible. No big deal (in first iteration only maxIndex reachable works fine) 2,1,0,4 --> not possible since max index never cross the index of 0 which is 2. When the iteration reaches index 3(4) it'll see than curIndex is strictly more than maxindex(2). So that's our flag to return false. """ class Solution: def canJump(self, nums: List[int]) -> bool: maxIndexReachable = 0 n = len(nums) target = n - 1 for i in range(n): if i > maxIndexReachable: return False maxIndexReachable = max(maxIndexReachable, i+nums[i]) return maxIndexReachable >= target
@top_10_2.O
@top_10_2.O 4 ай бұрын
We can go from last index to 1st If we can't go then false else true
@sumitnagar8367
@sumitnagar8367 3 ай бұрын
bool canJump(vector& nums) { int current=0; int available=0; for(int i=0;iavailable){ available=current; } else if(available==0){ return false; } available--; } return true; }
@mohit7717
@mohit7717 Ай бұрын
Before watching Greedy Algorithm, I thought it was too tough. but after watching ohh it's the easiest one.
@hashcodez757
@hashcodez757 2 ай бұрын
"UNDERSTOOD BHAIYA!!"
@TheBaljitSingh
@TheBaljitSingh 5 күн бұрын
why solution using normal recursion not working?
@nikhilkolliboyina9831
@nikhilkolliboyina9831 6 ай бұрын
Hey striver,in DSA a to z course there is no video on Java collections
@roshan3224
@roshan3224 2 ай бұрын
Hello guys !!! please pay attention iterate the i or n upto size not size -1 else it will not pass the few test cases :)
@KKKK-pl8yf
@KKKK-pl8yf 6 ай бұрын
Stack and Queue ki playlist daaldo bro please, eagerly waiting. Mail bhi kia thha poochhne ke lie but you did not reply
@prishaaagrawal
@prishaaagrawal 29 күн бұрын
bool canJump(vector& nums) { int j=nums.size()-2; while(j>=0){ if(j+nums[j]>=j+1) j--; else { int k=j-1; while(k+nums[k]=0){ k--; } if(k
@UECAshutoshKumar
@UECAshutoshKumar 2 ай бұрын
Thank you
@suryabhamukhopadhyay5682
@suryabhamukhopadhyay5682 4 ай бұрын
Please add the links of these new videos to the A2Z Dsa sheet
@rudrakshamishra2668
@rudrakshamishra2668 2 ай бұрын
yes this solution is not passed on the[3,2,1,0,4] this case on leet code only 146 / 172 testcases passed
@naitikmalav776
@naitikmalav776 2 ай бұрын
it does, but try for loop until last element for(int i=0; i maxIndex) return false; maxIndex = max(maxIndex, i+nums[i]); }
@DeadPoolx1712
@DeadPoolx1712 Ай бұрын
UNDERSTOOD;
@apmotivationakashparmar722
@apmotivationakashparmar722 Ай бұрын
Thank you So much
@shilparaghav6831
@shilparaghav6831 2 ай бұрын
This above explained solution is not working for [3,2,1,0,4] if we are starting from starting index
@harshitsinghbaghel1789
@harshitsinghbaghel1789 Ай бұрын
what's wrong in this it will be false in answer will not be able to reach till the last
@teeyaojha4365
@teeyaojha4365 5 ай бұрын
please add link to this video in your a2z sheet
@naviyas2305
@naviyas2305 Ай бұрын
thank you so much bro
@rudrakshamishra2668
@rudrakshamishra2668 2 ай бұрын
please make a solution on the right answer
@Cool96267
@Cool96267 6 ай бұрын
Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses. Would also like your insights on the point : While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?
@abhavgoel9390
@abhavgoel9390 4 ай бұрын
by not watching the video first and try to solve the question beforehand. And you talk about laziness to solve a question that help you land a job bro, you shouldn't be even asking this question if you were motivated enough
@subee128
@subee128 3 ай бұрын
Thank you very much
@KKKK-pl8yf
@KKKK-pl8yf 6 ай бұрын
Good morning striver !
@ayushgaurabh8604
@ayushgaurabh8604 5 ай бұрын
awesome
@mohit8299
@mohit8299 5 ай бұрын
thanks for the solution
@thoughtsofkrishna8963
@thoughtsofkrishna8963 4 ай бұрын
waiting for Strings playlist
@chaitralishinde7815
@chaitralishinde7815 4 ай бұрын
Best solution
@riyanshbiswas
@riyanshbiswas 3 ай бұрын
"Someone did touch you" sounds so wrong haha
@SiddharthSingh-un8ue
@SiddharthSingh-un8ue 5 ай бұрын
what if there are multiple zeroes in the array; than the method doesn't seem to work?
@ineshdheer7236
@ineshdheer7236 4 ай бұрын
why
@Professor-du2pf
@Professor-du2pf 5 ай бұрын
Mind Benging brooo
@dharmrajhembram6445
@dharmrajhembram6445 5 ай бұрын
prefix coding pattern
@kshitijjha6737
@kshitijjha6737 5 ай бұрын
Understood
@MJBZG
@MJBZG 2 ай бұрын
understood
@great.Indian.culture
@great.Indian.culture 3 ай бұрын
Bhai kya padhate ho ap never understood anything in my life what u taught
@Shantisingh-tz5sr
@Shantisingh-tz5sr 3 ай бұрын
watch pogo
@prerakunhale50
@prerakunhale50 6 ай бұрын
please bring the string video first .A humble request from us
@gugulothsrilakshmi8729
@gugulothsrilakshmi8729 5 ай бұрын
please,anyone can explain intution behind it, why he is not using dp here
@rohithkarthikeya2686
@rohithkarthikeya2686 5 ай бұрын
This is similar to Buy and sell stock 1 here basically we need to figure out whether we can able to jump to last index or not so let's say as he mention from particular index I he can jump to at max 6 and try to traversing the array by calculating from that index what is the jump possobile at any moment lets at index I he can go to max of x but to reach till I the max possible jump we can take is y if y
@KartikeyTT
@KartikeyTT 5 ай бұрын
ty sir
@khushalgandhi5157
@khushalgandhi5157 3 ай бұрын
can anyone explain me how is this greedy
@valiz2628
@valiz2628 2 ай бұрын
yes, for every step the mindset to jump maximum so its greedy method
@parasjeeprep3206
@parasjeeprep3206 6 ай бұрын
paaji tussi great ho taufa kabul karo
@Ahnos
@Ahnos 6 ай бұрын
😂😂
@immrhrr
@immrhrr 6 ай бұрын
@chandansinghbamba8295
@chandansinghbamba8295 3 ай бұрын
waste 3500 on pw java course which is not 1% of your free resource
@SibiRanganathL
@SibiRanganathL 2 ай бұрын
bruh
@mohammadumaidansari5087
@mohammadumaidansari5087 3 ай бұрын
Understood
@prerakunhale50
@prerakunhale50 6 ай бұрын
please bring the string video first .A humble request from us
@adityapandey23
@adityapandey23 3 ай бұрын
Understood
@saimasyeda6544
@saimasyeda6544 6 күн бұрын
Understood
L5. Jump Game - II | Greedy Algorithm Playlist
16:45
take U forward
Рет қаралды 67 М.
L6. Job Sequencing Problem | Greedy Algorithm Playlist
16:07
take U forward
Рет қаралды 51 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 93 МЛН
Каха и лужа  #непосредственнокаха
00:15
СКОЛЬКО ПАЛЬЦЕВ ТУТ?
00:16
Masomka
Рет қаралды 3,3 МЛН
3 Sum | Brute -  Better - Optimal with Codes
38:25
take U forward
Рет қаралды 352 М.
L11. Aestroid Collisions | Stack and Queue Playlist
17:28
take U forward
Рет қаралды 26 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 147 М.
L12. Candy | Slope Approach Intuition Based
30:10
take U forward
Рет қаралды 36 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 736 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 687 М.
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН