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-du2pf5 ай бұрын
After watching the DP Approach this greedy code is far very easy .
@LokeshSharmaCP5 ай бұрын
i thought about recursion approach but this is really easy and optimal
@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-sy6br5 ай бұрын
waiting for String playlist ❤ and till now all the videos of greedy are osm
@Paradox_16 ай бұрын
Radhe Radhe bhaiya 💖
@Josuke2176 ай бұрын
Waiting for strings ...
@KartikeyTT4 ай бұрын
do you come to menace and monk streams
@Josuke2174 ай бұрын
@@KartikeyTT no
@KartikeyTT4 ай бұрын
@@Josuke217 okay
@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.O4 ай бұрын
We can go from last index to 1st If we can't go then false else true
Before watching Greedy Algorithm, I thought it was too tough. but after watching ohh it's the easiest one.
@hashcodez7572 ай бұрын
"UNDERSTOOD BHAIYA!!"
@TheBaljitSingh5 күн бұрын
why solution using normal recursion not working?
@nikhilkolliboyina98316 ай бұрын
Hey striver,in DSA a to z course there is no video on Java collections
@roshan32242 ай бұрын
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-pl8yf6 ай бұрын
Stack and Queue ki playlist daaldo bro please, eagerly waiting. Mail bhi kia thha poochhne ke lie but you did not reply
@prishaaagrawal29 күн бұрын
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
@UECAshutoshKumar2 ай бұрын
Thank you
@suryabhamukhopadhyay56824 ай бұрын
Please add the links of these new videos to the A2Z Dsa sheet
@rudrakshamishra26682 ай бұрын
yes this solution is not passed on the[3,2,1,0,4] this case on leet code only 146 / 172 testcases passed
@naitikmalav7762 ай бұрын
it does, but try for loop until last element for(int i=0; i maxIndex) return false; maxIndex = max(maxIndex, i+nums[i]); }
@DeadPoolx1712Ай бұрын
UNDERSTOOD;
@apmotivationakashparmar722Ай бұрын
Thank you So much
@shilparaghav68312 ай бұрын
This above explained solution is not working for [3,2,1,0,4] if we are starting from starting index
@harshitsinghbaghel1789Ай бұрын
what's wrong in this it will be false in answer will not be able to reach till the last
@teeyaojha43655 ай бұрын
please add link to this video in your a2z sheet
@naviyas2305Ай бұрын
thank you so much bro
@rudrakshamishra26682 ай бұрын
please make a solution on the right answer
@Cool962676 ай бұрын
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?
@abhavgoel93904 ай бұрын
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
@subee1283 ай бұрын
Thank you very much
@KKKK-pl8yf6 ай бұрын
Good morning striver !
@ayushgaurabh86045 ай бұрын
awesome
@mohit82995 ай бұрын
thanks for the solution
@thoughtsofkrishna89634 ай бұрын
waiting for Strings playlist
@chaitralishinde78154 ай бұрын
Best solution
@riyanshbiswas3 ай бұрын
"Someone did touch you" sounds so wrong haha
@SiddharthSingh-un8ue5 ай бұрын
what if there are multiple zeroes in the array; than the method doesn't seem to work?
@ineshdheer72364 ай бұрын
why
@Professor-du2pf5 ай бұрын
Mind Benging brooo
@dharmrajhembram64455 ай бұрын
prefix coding pattern
@kshitijjha67375 ай бұрын
Understood
@MJBZG2 ай бұрын
understood
@great.Indian.culture3 ай бұрын
Bhai kya padhate ho ap never understood anything in my life what u taught
@Shantisingh-tz5sr3 ай бұрын
watch pogo
@prerakunhale506 ай бұрын
please bring the string video first .A humble request from us
@gugulothsrilakshmi87295 ай бұрын
please,anyone can explain intution behind it, why he is not using dp here
@rohithkarthikeya26865 ай бұрын
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
@KartikeyTT5 ай бұрын
ty sir
@khushalgandhi51573 ай бұрын
can anyone explain me how is this greedy
@valiz26282 ай бұрын
yes, for every step the mindset to jump maximum so its greedy method
@parasjeeprep32066 ай бұрын
paaji tussi great ho taufa kabul karo
@Ahnos6 ай бұрын
😂😂
@immrhrr6 ай бұрын
❤
@chandansinghbamba82953 ай бұрын
waste 3500 on pw java course which is not 1% of your free resource
@SibiRanganathL2 ай бұрын
bruh
@mohammadumaidansari50873 ай бұрын
Understood
@prerakunhale506 ай бұрын
please bring the string video first .A humble request from us