After watching previous buy and sell stocks problems, I solved variant IV, with cooldown and with fee by my own, without watching the videos. 1-2 months back, I had no concept of Recursion and DP, and now, I am confident to solve any kind of recursion and DP. Thank you so much bhaiyaaa. Huge respect to you. 🙏🙏🙏🙏
@kazuma08032 жыл бұрын
Same
@bite091_jamee72 жыл бұрын
same
@asdsd-wu4yw Жыл бұрын
those who are seeing this kind of comments dont worry u can also solve these problems ,there is only one word of change in code as compared to previous code,these are very simple
@satendra6200 Жыл бұрын
same here bro
@happysatan555420 күн бұрын
Where are u working now bro
@nupur31772 жыл бұрын
Want to share the significant difference between this channel and other million channels who claim that they teach DSA, other channels explain the code or sometimes when channel is good ,intuition as well, but striver neve fails to teach the concept behind every f problem, he will explain one problem, and you can do others extremely fast(relatively) and on your own as well because he did not give you a stupid reading of code, but he explained you how to generate the f code. Only Aditya Verma bhaiya's channel along with this channel has even come close to this level of DSA teaching, this has surpassed the GOD level as well. Kudos to striver !!!!
@anandkalpe21552 жыл бұрын
Solved previous two and this problem by my own just by watching your first two videos on stocks. Completed from recursion upto space optimization...Feeling good. Thanks striver for making it very simple !
@Tejas-CoderАй бұрын
After watching buy and sell stocks problems, I solved this problem by my own without any hints or watching videos. Thank you so much Sir!
@yeddulaharshitha4405 Жыл бұрын
Thats insane ! I started DP 3 days ago. On the 4th day I am on this lecture. After watching all the buy and sell stocks, I was able to get the crisp of this in just few seconds.Kudos to you!!
@jayrathod795710 ай бұрын
ohh just how??? for me,it took 1 month to reach till here...
@aditya14-023 ай бұрын
@@jayrathod7957++
@calvincruzada10162 жыл бұрын
watched from 1-40 of your DP videos. I feel like I can solve any DP problem now, thanks man :)
@parthsalat2 жыл бұрын
Then why are you commenting on video 39?
@calvincruzada10162 жыл бұрын
@@parthsalat rewatching? I don't have photographic memory unfortunately :(
@parthsalat2 жыл бұрын
@@calvincruzada1016 In that case, I recommend you to use notion. It's the best note taking tool out there.
@calvincruzada10162 жыл бұрын
@@parthsalat Good advice, I love notion! Been using it for years, it's my brain dump so I don't have to keep much in my head 😂
@MEGHAPRAJAPATI-r3mАй бұрын
we can space optimize because we don't have to carry entire row for i+2, only have to carry dp[i+2][1]. so we can use a variable to store it and update it with next2 = next[1]. this is the space optimized solution: int maxProfit(vector& prices) { int n = prices.size(); vector next(2, 0), curr(2, 0); int next2 = 0; for(int i = n-1; i >= 0; i--) { curr[0] = max(next2 + prices[i], next[0]); curr[1] = max(next[0] - prices[i], next[1]); next2 = next[1]; next = curr; } return next[1]; }
@piyushpandey2442 жыл бұрын
i also tried using one extra variable for the two ahead variable here is the code int Maxprofit(vector&prices){ int n = prices.size(); vectorahead(2,0); vectorcurr(2,0); int twoahead = 0; for(int ind =n-1;ind>=0;ind--){ for(int buy=0;buy
@sricharanreddy9989Ай бұрын
After understanding the pattern i could solve these questions listening to music in like 5mins , your explanation is just amazing bro ❤🔥
@viratlover62067 ай бұрын
I was able to solve this problem from recursion to the space optimization by own. Thank u so much sir!
@SumitKeshariMCS Жыл бұрын
Solved it using 3D DP concept taught by you. I didnt watch the video and tried to solve it by myself. class Solution { private: int solve(int index,int n,int buy,int cool,vector& prices,vector& dp) { if(index==n) return 0; if(dp[index][buy][cool]!=-1) return dp[index][buy][cool]; int profit; if(buy==0 && cool==0) { int op1 = solve(index+1,n,0,cool,prices,dp); int op2 = -prices[index]+solve(index+1,n,1,cool,prices,dp); profit = max(op1,op2); } else profit = solve(index+1,n,0,0,prices,dp); if(buy==1) { int op1 = solve(index+1,n,1,cool,prices,dp); int op2 = prices[index]+solve(index+1,n,0,1,prices,dp); profit = max(op1,op2); } return dp[index][buy][cool] = profit; } public: int maxProfit(vector& prices) { int n = prices.size(); vectordp(n+1,vector(2,vector(2,0))); for(int index=n-1;index>=0;index--) { for(int buy=0;buy
@yugal8627 Жыл бұрын
Bhaiya watched all your DP videos till now and I'm able to solve the previous and this questions by myself. Thanks a lot..🙏🏻🙏🏻
@mdamirhussain2095Ай бұрын
Understood... Thank u Striver
@ntgrn-pr5yx29 күн бұрын
Thank you striver , Understood
@lexeve5298 Жыл бұрын
Thanks striver , I was able to come up with the logic myself
@UECAshutoshKumar5 ай бұрын
Thank You! Understood!!!!
@princeshubham26 Жыл бұрын
solved by myself ,,,self confidence is building
@ishangujarathi10 Жыл бұрын
Understood, got the logic by just reading the problem on leetcode and even did it myslef with both memoization and tabulation technique!!! Tysm Striverrrr!!!
@preetkatiyar9692 жыл бұрын
Sir you are really a gem . These topic are really tough but you teach like this is just a mind game. Best teacher
@aligohar17082 жыл бұрын
the power of cp can be seen by his speed .... insanely impressed... I don't know, this guy does not even need interviews for companies, he should just be directly hired
@divyansh22122 жыл бұрын
I solved this question on my own without watching this video before. Thankyou Bhaiya
@shubhamjaiswal1325 Жыл бұрын
Best Explanation so far. Very intuitive. Thanks a ton
@rishabhgupta9846 Жыл бұрын
understood,able to solve by myself.Gaining confidence to solve dp questions
@DevashishJose10 ай бұрын
Understood Thank you so much.
@Sid-ci1cd3 ай бұрын
UNDERSTOOD!!
@satyamgupta14462 жыл бұрын
I was able to do this question on my own. Thanks striver for helping us out...😇
@Superheroic_Anime2 жыл бұрын
Understood bhaiya !!! By just watching first 6 minutes of your video.
@shubhankar_naik Жыл бұрын
I was able to solve without seeing your solution thanks for the great explanations
@johnsimon815820 күн бұрын
thanks for this awesome content
@VinayKumar-xs6el2 ай бұрын
Again i solved after pausing at 2:23 & i did on my own thanks from recursion to space optimization (java people has to use clone() for assigning arrays). not only this i did next lecture problem as well even without opening that from recursion to space optimization. thanks is small thing
@ganeshkamath892 жыл бұрын
Thanks Striver. Understood.
@mohitsingh132 ай бұрын
Understood ❤
@santoshb7776 Жыл бұрын
Understood sir 🙏🙏
@vivekkumarsingh178Ай бұрын
Why we cannot optimise space when their was 2 for loops and just by removing one we are doing same thingh 😢???
@atheisth2373 Жыл бұрын
Thanks a lot...Striveerr
@rishabmalhotra69802 жыл бұрын
I tried to space optimize it by mytself for 6 variables and I guess i fucked my brain so much that i started questioning my existence. You explained it so well thanks strive.
@uditgarg65085 ай бұрын
put k = n/2 and ind+2 in previous , runs fine
@divakarv33032 жыл бұрын
Space Optimisation using 4 variables and 4 lines of code int a=0,b=0,c=0,z=0; for(int i=prices.length-1;i>=0;i--){ int x=z; a=Math.max( -prices[i] + b, a); b=Math.max( prices[i] + c , b); c=x; z=a; } return a; Thanks a lot striver for Graph,Tree and DP series
@akashsahu2571 Жыл бұрын
yes
@bibs24 Жыл бұрын
Thank you
@LBK3 Жыл бұрын
understood ❤
@Harsh-jc2bz2 ай бұрын
diid it by myself
@dum03 ай бұрын
damn i cant believe , i solved this problem under few seconds only listening question , actually getting gud
@shivambajpeyi90082 жыл бұрын
Understood, did this one by myself hehe
@aditya14-023 ай бұрын
Thanks!
@nihalsingh6233 Жыл бұрын
Understood
@himanshuagrawal80122 жыл бұрын
Thanku so much Raj bhaiya for DP videos , now i m feeling very much confident in DP, I can now teach to the interviewer as well 😜😜😅😅 just_kidding #UNDERSTOOOODDDDDDDD
@Himani-t3g21 күн бұрын
understood!
@ratinderpalsingh5909 Жыл бұрын
Understood, sir. Thank you very much.
@abdalla442511 ай бұрын
Understood!
@asheshkaran5843 Жыл бұрын
UNDERSTOOD!!!!!
@HarshKumar-ip5nr Жыл бұрын
I have solved this question using 3d DP. Is this solution ok for the interview?
@googleit2490 Жыл бұрын
DP revision: Was applying some other complex logic, had to watch the video upto 5:28 Nov'18 2023 02:51 pm
@rishabhagarwal80492 жыл бұрын
Understood Sir, Thank you very much
@xpyder2 жыл бұрын
I think you can space optimize this easily by using Mod 3 on your array indexes (dp[ (ind+1)%3 ][0] and dp[ (ind+2)%3 ][1], etc), is this correct?
@pusarlaaishwarya50352 жыл бұрын
Canyou explain this condition please?
@me.deepaksharma2 жыл бұрын
Thank You :)
@keen_kartik Жыл бұрын
This man is genius
@kumarpurushottam632 Жыл бұрын
Thanks a Lot Striver : )
@adityasaxena6971 Жыл бұрын
Thanks Striver
@willastralian7141 Жыл бұрын
WHAT IS IT WITH THESE FUCKING EXCELLENT INDIAN TUTORS DUDE. CAN'T BECOME A SUPER POWER QUICK ENOUGH
@Hello-ro6hr2 жыл бұрын
UNDERSTOOD ... Ideally at 15.09 it should be front1[1]...
@VivekGawande1 Жыл бұрын
Great explanation!
@hemantpatel1413 Жыл бұрын
understood.
@parvahuja76186 ай бұрын
thankyou
@kartikrameshchavan6662 Жыл бұрын
Understood 🙏
@sauravchandra10 Жыл бұрын
Understood, thanks!
@jivanninawe31902 жыл бұрын
Striver bhahiya LIS pr dp banaho na bhaut question ke sath lis nahi samja muje
@verma_jay Жыл бұрын
understood
@ajitzote61032 жыл бұрын
understood!
@rishabhraj823310 ай бұрын
solved without watching 😸👽
@pankajmittal10026 ай бұрын
understood!!
@mriduljain6809 Жыл бұрын
Understood Bhaiya..
@parthsalat2 жыл бұрын
Understood kaka
@tasneemayham974 Жыл бұрын
DONE!!
@Professor-du2pf10 ай бұрын
"US"
@aditithakur6226 Жыл бұрын
Understood Sir.
@VikashYadav-px8ei Жыл бұрын
Understood 🎉
@gangsta_coder_122 жыл бұрын
Understood 💯💯💯
@venkateshvenky28802 жыл бұрын
#understood
@vaishnavithakur64602 жыл бұрын
Understood so very well!!!!
@gaboja__goo Жыл бұрын
thx very much.
@parshchoradia9909 Жыл бұрын
Understood Sir!
@sameersahu45692 жыл бұрын
Understood!!!Thank you
@nimmalavishnu30442 жыл бұрын
Superb explaination striver
@dheerajshukla70085 ай бұрын
thats amazing
@gurubhargava69502 жыл бұрын
Understood!!
@gentleman7060 Жыл бұрын
In any videos of buy and sell stock u didnt mention overlapping. Why?
@oblivion_59102 жыл бұрын
understood
@THEAMITESHRANJANАй бұрын
"us"
@urvashi2410 Жыл бұрын
This was so good!!
@shubhigupta56892 жыл бұрын
Understood🌻
@curiouscoder9566 Жыл бұрын
great content
@satyampande6842 жыл бұрын
understood!!
@Harshit1262 жыл бұрын
Understood, thanks
@rohalkurup13502 жыл бұрын
Understood !!!!
@gopalaggarwal9649 Жыл бұрын
US
@suheabkhan25462 жыл бұрын
understood!!!!!!!!
@calderanoadi59822 жыл бұрын
UNDERSTOOD
@vader9782Ай бұрын
well i did this i created an extra space for cooldown in the vector class Solution { public: int maxProfit(vector& prices) { int n=prices.size(); vector curr(3,0),next(3,0); next[0]=prices[n-1]; for(int i=n-2;i>=0;i--) { for(int buypt=2;buypt>=0;buypt--) { int profit=0; if(buypt==2) profit =next[1]; else if(buypt==1) { int buy=next[0]-prices[i]; int hold=next[1]; profit = max(buy,hold); } else { int sell=prices[i]+next[2]; int hold=next[0]; profit = max(sell,hold); } curr[buypt]=profit; } next=curr; } return next[1]; } };