So, everyone asks to not put spoiler in titles, I put this on the basis of my experience with other leetcode tutorials of my time (eg: 3 years back, when i was preparing for internship, whenever i search for any leetcode problem, there used to come 1 channel's video most often, i'll not name it, though it was good, but as soon as there used to hard follow up of any problem or hard variant, he used to skip it & i hated that part everytime, that atleast write in beginning or tell you will teach very basic stuff) . Thus, i write in title or tell in beginning that what all you will get from video & look for that part accordingly. (Why DP, was very specific to me! I just thought, somehow DP was intuitive to me but later realised that it can't solve, so yeah discussed that too 🌚)
@rev_krakken706 ай бұрын
I am happy today, since i think this is the first time i came up with an algorithm on my own and the fact that i did not consider any existing template and stuff before coding the solution, and I was able to beat 100% with my solution
@kgjr.62246 ай бұрын
I rely wish your channel should grow because in todays world where other youtube channels as selling dreams this man is rely spreading real content and with huge amount of consistency
@sanket32366 ай бұрын
O(1) space approach : Suppose y > x in that case we have to remove first "ba" For that we can traverse the string with keeping count of b now whenever a occur & b's count > 0 we have found "ba" So increase the ans, decrease the count for b. Also we need to reset the b's count when any other char occur like bbbbx. Now then all the "ba" cases are done now we need to remove the "ab" cases, so for that we need all a that didn't make it in "ba". Basically all a for which there was no previous b to make a "ba" pattern, these all a can make ab pair so count all such a's and then increase the ans by min(cn(a), cn(b)) * min(x, y). This solution got accepted if anyone is looking for o(1) space approach
@krutikadave45346 ай бұрын
maqsad string 😁 this channel is the OG of daily challenge leetcode!
@iamnoob75936 ай бұрын
Superb explanation , Thanks
@varunjain39476 ай бұрын
Thankyou so much bro amazing explanation💯
@Ayush372626 ай бұрын
Bro you are amazing 🙏
@akshaanshsrivastava98176 ай бұрын
Thanks Sir. These types of videos help me with intuition and approach..
@mayanktandon69426 ай бұрын
THIS IS LITERALLY BY FAR THE BEST F**ING EXPLANATION THERE WALKED THROUGH THE THOUGHT PROCESS FROM THE BEGINNER POV TO OPTIMIZATION , LOVED IT ❤
@IK-xk7ex6 ай бұрын
Thank you! It's interesting technique with modifying the string in place. Hmm
@ProtoS-c8x6 ай бұрын
25:52 - Overwriting
@cenacr0076 ай бұрын
❤
@abhinavnarula73006 ай бұрын
Is the second approach some kind of pattern or is it only applicable to this question only?
@vikasshokeen60446 ай бұрын
Naah, that maqsad string got me 💀
@naamnhibataunga58976 ай бұрын
this was my solution : class Solution { public: int point(string &s,string target, int p){ int total=0; string str=""; for(char c:s){ if(!str.empty() && string(1, str.back()) + c==target){ str.pop_back(); total+=p; } else{ str+=c; } } s=str; return total; } int maximumGain(string s, int x, int y) { string s1="ab", s2="ba"; if(y>x){ swap(s1,s2); swap(x,y); } return point(s,s1,x)+point(s,s2,y); } };
@theerock-e3i6 ай бұрын
please solve leetcode 913 cat and mouse problem
@theerock-e3i6 ай бұрын
please solve leetcode 913 cat and mouse
@sriramadithya91286 ай бұрын
Hi Aryan, I have been learning DSA for a month, and I am solving daily challenges in a leetcode, I used to see your videos for understanding a problem bro, Thanks for your work. But my question is when I see a problem I cannot solve it by myself. It feels like I am not improving anything 😞I always look for a solution. Did you have the same feeling when you were learning DSA, How did you overcome this?
@AnonymousAnonymous-ug8tp6 ай бұрын
It is important to use pen and paper to properly understand the problems and dry run through the test cases to understand the nitty grittys of the problem. It will give you better insights to the problem and help to develop your own solution.
@sriramadithya91286 ай бұрын
@@GalaxyStart62 yea bro, I lost all my confidence today after seeing this problem. But as you said I need to solve more problems to get muscle memory and problem solving skills. Hope I will get soon.
@sriramadithya91286 ай бұрын
@@AnonymousAnonymous-ug8tp Yes bro I have been taking notes for every problem. First I will try to solve it without looking solution, But honestly I couldn't do it. I lost all my confidence today and messaged here. But I am not going to give up 🙂
@iamnottech89186 ай бұрын
The catch is to do all concepts once then dpp or along with like after love or striver sheett
@advaithmahendrakar6 ай бұрын
class Solution { public int maximumGain(String s, int x, int y) { Stack st = new Stack(); int ans =0; for(int i =0 ; i < s.length() ; i++){ System.out.println(st); if(s.charAt(i) == 'a'&& !st.isEmpty() && st.peek() == 'b' ){ if(y > x){ st.pop(); ans += y; System.out.println(ans); }else{ st.push(s.charAt(i)); } }else if(s.charAt(i) == 'b' && !st.isEmpty() && st.peek() == 'a'){ if(y > x){ st.push(s.charAt(i)); }else{ st.pop(); ans += x; System.out.println(ans + "x>"); } }else{ st.push(s.charAt(i)); } } while(!st.isEmpty()){ char ch = st.pop(); if(!st.isEmpty() && st.peek() == 'a' && ch == 'b'){ ans += x; }else if(!st.isEmpty() &&st.peek() == 'b' && ch == 'a'){ ans += y; } } return ans; } } Why is this solution wrong please anyone explain?