Tomorrow's quote from my side:- Don't have enough energy, felt tired, felt lazy, don't want to do it anymore, felt lonely, and on and onn.... Just one question) Who Cares..?
@suryapratap22192 күн бұрын
accha nhi h
@Aryan-cy7cuКүн бұрын
some motivation from me : - No trees can grow to heaven ,unless it's roots reach down to hell.
@aryansinha1818Күн бұрын
bruhhh!! Damn it's so good
@AbhayGupta-m4vКүн бұрын
What you are doing is speaking so loud that i cannot hear what you are saying
@jain51842 күн бұрын
Honestly, I used to be addicted to endlessly scrolling through KZbin and Instagram. It's been two months now since I stopped, and instead of wasting time on that, I've been focusing on solving daily problems, thanks to Mik Bhaiya. Thank you so much!
@codestorywithMIK2 күн бұрын
That's amazing to hear! Keep up the great work! 💪😇
@jain51842 күн бұрын
@@codestorywithMIK thnku mik U helped a lot 🙏
@aws_handles2 күн бұрын
You are the only youtuber who seem to care more on video content, quality, information, knowledge instead of views,. Creating such detailed long videos take time for sure and you put so much effort every day. I respect you man. Thank you dil se.
@unknown47896Күн бұрын
yes bro...i agree with u
@chinmaygupta2277Күн бұрын
I have been following your channel for the last few months and I have achieved a consistency of 3 months now. Your explanation is just amazing. I have a request, can you please also share the leetcode weekly and biweekly contest solutions tutorial.
@codestorywithMIKКүн бұрын
Thanks for your feedback! I'll definitely keep that in mind for future videos. 🙏😇 Today’s contest Qn-3 was a good problem , i uploaded its video - kzbin.info/www/bejne/eGbEeqSCpppjlZosi=u0PYH6Alk51-d2_- Hope this helps ❤️🙏
@chinmaygupta2277Күн бұрын
@@codestorywithMIK Thankyou so much for considering my request. Yes I checked the third solution, amazing explanation once again.🥰
@Phobos221BКүн бұрын
These explanations are so good , people like you make teaching such a noble thing. Hats off!!!
@rickdutta942Күн бұрын
East and West MIK is best. I haven't found anyone who put that much details and effort into explaining. Live longer man💖
@shivam-mp4vr2 күн бұрын
yaar laga aaj to fas hi gya din bana dete ho video se subah subah
@thefinancialdiet4458Күн бұрын
Mik bhaiya want 2 things we the students are requesting u apka samjaya hua pura thought process dimag me jata hai even kabhi pehla consistent nhi tha apka subha motivation and then video thnku for all this but 1 apki sde sheet 2 dsa pattern recognition ispr video laao 3 for beginners to advance dsa course again ye app pr hai ki app launch karna chahta ho kuki honestly apka jesa ytber mene nhi dekha if u will for course jisme sabkuch included i will be infact bahut log course ke member hoga Again thanku if possible for u then it will be great help as u travel daily firbhi itna quality teaching content thought process salute u men 🫡
@mohammadaftabansari6882Күн бұрын
Thanks for such thorough explanations. Keep them coming.
@ujjwalsharma67732 күн бұрын
thank you bhaiya.. i was able to think of the second approach on the first try because of your older video intuitions, however was not able to think that i need to pass the string twice.. But the fact that i was even able to complete half of it feels really nice and its all because of you.. thank you so much
@Itisingh-mm8jdКүн бұрын
Was really waiting for your explanation.. thanks 🎉 🙏
@aastikofficial6100Күн бұрын
Sir just one question aap jb problem solve krte ho na to kafi acha thought process or say intution jo h na vo kafi achi build krte ho like kitna time lgega aapke jaisa sochne me like mne is question o 1st approach to khud kr li thi with same intution but that second one is damn good .... Now i recommend everyone to once checkout yout channel ... Thank you so much ❤❤..... Mostly yt videos just gave sol but you taught us thought process thats why i liked your videos 🔥
@RupaKumari-m3v5uКүн бұрын
you have a superpower to make tough problems easy.
@thefinalfit2 күн бұрын
Finally 🎉 Thank you for posting even while travelling
@khushiiyer14Күн бұрын
Truely, a great explanation with complete patience 💯👏
@dayashankarlakhotia49432 күн бұрын
Motivation of day. 90%consistency will take you further then waiting for the 'perfect day',time or opportunity 🎉❤
@GauravDuseja-t6q19 сағат бұрын
Best Explanation thanku bhaiya
@wearevacationuncoverers2 күн бұрын
Wow. You are the only one whom I can expect to bring detailed videos like these for intuition building. I already knew that we can solve it using 2-pass but needed few hints. got it now. thank you so much.
@NaveenKumar-do6csКүн бұрын
Sir , the second approach was just fire.. that is really a smashing thought.
@сойка-и8йКүн бұрын
Couldn't agree more, mind blowing solution
@chipmunk_godКүн бұрын
MIK, your video on KMP was the best, the 1 hour was totally worth it, i really want you to make a similar video on Rolling hash, string hashing and rabin karp algorithm also with the same energy Love your work !!
@rockykumarverma9802 күн бұрын
Thank you so much Bhaiya ji 🙏🙏🙏
@joydeepgharami4032 күн бұрын
Thank you sir,1st comment
@pranavmaiya43864 сағат бұрын
the second approach was really good
@PriyanshuSingh-qi3dk2 күн бұрын
2nd approach is really so good and easy you are great teacher bhaiya
@codestorywithMIK2 күн бұрын
Glad you found the second approach helpful! 😊🙏
@сойка-и8йКүн бұрын
@@codestorywithMIKbhaiya Aapko ye second approach ka initiution kaise aaya... Ya phir ye koi Algorithm hai ?? Jaise fast slow pointer
@vyombajaj482 күн бұрын
Your explanation is so good man
@codestorywithMIK2 күн бұрын
I'm glad you found it helpful! 😇❤️🙏
@joydeep-halderКүн бұрын
Bhaiyaaa kya tha vo approach 2 🤯🤯 Maaza aa gya
@SHUBHAMRAJPAL-w9mКүн бұрын
Leetcode Problem 678. Valid Parenthesis String I guess this is the same problem that you are referring to in the video
@himanshujain9933Күн бұрын
Best Explanation Ever!
@aizad786iqbal2 күн бұрын
hamare college mai kuch nahi padhaya gya tha dhang se..regarding DSA
@EB-ot8uu2 күн бұрын
yayyy, MIK is here. I was stuck in one part. Now it's crystal clear and I solved it easily. Thank you so so much
@insanecode9374Күн бұрын
amazing solution keep up bro !!
@bhupendrakalal1727Күн бұрын
bhAIYA DIRECT optimal approach dimag me aa gayi thi , bs me ek hi bar me open aur close dono ka count store kr raha tha esiliye test case fat gaye , thank uu uuu
@codestorywithMIKКүн бұрын
Awesome 👌
@bhupendrakalal1727Күн бұрын
@codestorywithMIK finally you replied🥳🥳🥳
@harjotanand8342 күн бұрын
This video was " Are Bhai Bhai Bhai Bhai Bhai ....."😅😅
@TanmayMankar-262 күн бұрын
In only one traversal we can check if our value doesn't go negative then at the end we have to check whether it is zero or not if it goes negative then it is false but otherwise the above condition
@sainipankaj2 күн бұрын
Sir Keep doing good work
@harshtiwari4162 күн бұрын
Sir it would be helpful if you covered sorting algorithms by making a separate playlist :)
@CSBAjay2 күн бұрын
Hi Mik , Can you cover contest problems too ? Your explanation is crystal clear 😊
@RitikaBaliyan-d7gКүн бұрын
amazing
@tareqaziz3929Күн бұрын
1614. Maximum Nesting Depth of the Parentheses to same
@ompandit45232 күн бұрын
thanks a lot bhaiya for those type of video
@gui-codes2 күн бұрын
Finally the legend is here. Was waiting for your exaplanation MIK.
@imPriyansh772 күн бұрын
me too bro :)
@EB-ot8uu2 күн бұрын
me too
@dss963Күн бұрын
This is extremely hard problem taking into account of edge cases.
@ShravanChoudhary-q1qКүн бұрын
thankyou sirji..
@knight-z1xКүн бұрын
thankyou sir!!
@parthokrКүн бұрын
"Work in silence, let your success roar" reminds me something else.
@pradumyelame6462Күн бұрын
Hello mik bhaiya I’m a third-year CSE student, and in six months, placements will begin at my college. I've been following your videos for the past 4 months, and they’ve been really helpful. However, I still feel like I’m struggling to solve DSA problems independently, especially when it comes to thinking through a problem to its end. I work on DSA daily, but I’m unsure what I might be missing in my preparation. Could you please guide me on how to improve my problem-solving skills and logical thinking so please bhaiya bata do kuch?...
@sahebraojadhav97272 күн бұрын
Thank you mik
@coldcoke9254Күн бұрын
Sir do you have any tips to build own testcases for questions like these. Since there were so many cases coming to my mind when solving these that I couldn't think of a algorithm to solve this. But when you used you own testcases to explain the intuition I was easily able to understand the solution. So can you give me tips to come up with such test cases on my own?
@subhranilnandy04Күн бұрын
Consider the string, "( 0 0 0 ) )" [0 represents unlocked index]. Acc to your approach1, the 1st locked closing parenthesis (at idx 4) is matched with 1st opening locked parenthesis (idx 0), which is not the case here. Anyways, your approach passes all the testcases (along with this). So, I am a bit confused whether it's the correct approach to follow.
@manishv.81672 күн бұрын
Just a question why we need two traversal ?? Can't we do with one traversal for example you showed one where open = 2 from there we can return ans to be false, as we don't have matching parenthesis ???
@codestorywithMIK2 күн бұрын
I was waiting if someone would ask this Qn. Glad you asked. Thank you. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But remember the WHY ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@manishv.81672 күн бұрын
@codestorywithMIK awesome thanks
@amaannirban1107Күн бұрын
@@codestorywithMIK Would like to support Mazhar's response with example- s = "(()(" locked = "1101" right to left +2 but, ideally it should fail which will be catered in right to left
@gui-codes2 күн бұрын
14:02 - I paused the video and coded it within few minutes. Thank you so much MIK. One Qn, in interviews is it mandatory to solve using O(1) space ?
@imPriyansh772 күн бұрын
Yes, if the interviewer demands space optimization.
@gui-codesКүн бұрын
@@imPriyansh77 ok bhai
@gui-codes2 күн бұрын
Also, can you please post Qn-3 of today's contest. I have some doubts in it.
@sauravchandra10Күн бұрын
Really messed up the thinking. Had to see hints and arrive at this solution. Python implementation for the same: (btw the last approach was lit!) class Solution: def canBeValid(self, s: str, locked: str) -> bool: n = len(s) if n%2 != 0: return False lockedOpen, free = [], [] for i in range(n): if locked[i] == '0': free.append(i) else: if s[i] == ')': if len(lockedOpen) > 0: lockedOpen.pop() elif len(free) > 0: free.pop() else: return False else: lockedOpen.append(i) if len(lockedOpen) == 0 and len(free)%2 == 0: return True if len(lockedOpen) > len(free) or (len(free)-len(lockedOpen))%2 != 0: return False while lockedOpen: if lockedOpen[-1] > free[-1]: return False lockedOpen.pop() free.pop() return True
@harshugamer7776Күн бұрын
Second approach also can be done by single pass: class Solution { public boolean canBeValid(String s, String locked) { if(s.length() % 2 != 0) return false; int open = 0; int close = 0; for(int i = 0, j = s.length() - 1 ; i < s.length() ; i++, j--){ char ch1 = s.charAt(i); char ch2 = s.charAt(j); if(locked.charAt(i) == '0' || ch1 == '('){ open++; }else{ open--; } if(open < 0) return false; if(locked.charAt(j) == '0' || ch2 == ')'){ close++; }else{ close--; } if(close < 0) return false; } return true; } } this is single pass. right? or I have misunderstood?
@souravjoshi22932 күн бұрын
can you please post Qn-3 of today's contest. It was of graph Qn. Really thankful to you for providing such detailed videos everyday with consistency. You are my inspiration.
@harshitrajput356614 сағат бұрын
@@souravjoshi2293 bhai mei abhi new hu leetcode pr aap kab se leetcode problem solve kr rhe ho mujhe kuch tips chaiye thi bhai
@Heayu05Күн бұрын
Honestly, I have done 200+ qs in leetcode and now have the confidence to solve med level qs thanks to you 🙏, but I wanna ask is doing cp is good ? Many of my frnds are doing it as OA is generally getting tough !
@neerajgarg90962 күн бұрын
Java code : class Solution { public boolean canBeValid(String s, String locked) { int n = s.length(); if(n%2!=0){ return false; } int ob=0,cb=0,wc=0; for(int i=0; iob+wc){ return false; } } } ob=0; cb=0; wc=0; for(int i=n-1; i>=0; i--){ Character w = s.charAt(i); Character l = locked.charAt(i); if(l=='0'){ wc++; } else{ if(w=='('){ ob++; } else{ cb++; } if(ob>cb+wc){ return false; } } } return true; } }
@abhiramvanama52662 күн бұрын
Sir can you please explain the 3rd graph question from the leetcode contest 432 please sir
@002_adityaagrawal2Күн бұрын
Hello MIK, I have doubt on optimal solution you mentioned, 1)we will go from left to right than check if it will violate the condition or not, 2)than we will go right to left than check if it will violate the condition or not. I got the approach but when i am thinking of the solution in my mind came small doubt what would happen on first iteration we consider openclose parathesis as open parathesis now in case of second iteration we are considering as close parathesis. it would be very helpful if you consider my doubt. Thanks
@codestorywithMIKКүн бұрын
Glad you asked. One more guy asked this in the comment. Thank you for asking. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But remember the WHY ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@002_adityaagrawal2Күн бұрын
@@codestorywithMIK Thanks bhaiya, can we use second approach ,if we have to print balanced string?? As per my understanding we can not use.
@codestorywithMIKКүн бұрын
No printing a balanced string will not be a good idea with this approach. Stack is a better approach for that ❤️
@Sarthak24212 күн бұрын
Hey Mazhar! Please make a video on 3418. Maximum Amount of Money Robot Can Earn , if possible .
@italk-gj5kkКүн бұрын
here is the java code: class Solution { public boolean canBeValid(String s, String locked) { Stack fixed = new Stack(), flexible = new Stack(); int n = s.length(); for(int i = 0; i < n; i++){ if(s.charAt(i) == ')' && locked.charAt(i) == '1'){ if(! fixed.empty()) fixed.pop(); else if(! flexible.empty()) flexible.pop(); else return false; } else{ if(locked.charAt(i) == '0') flexible.push(i); else fixed.push(i); } } while(! fixed.empty()) if(flexible.empty() || flexible.pop() < fixed.pop()) return false; return (n & 1) == 0; } }
@crazygamerrohan98992 күн бұрын
Not able to think 2nd part of logic 33:34
@indianengineer58022 күн бұрын
two stack approach is extremely hard to think of!
@codestorywithMIKКүн бұрын
I totally agree. Actually i had solved similar problems where this 2 pass approach helps. That’s the reason i went for this approach as well. But I would like to give an example to share more on this approach. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But WHY does this work ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@lofireverbz-wy7goКүн бұрын
Little bit observation: same question as valid parenthesis string just consider 0 as *
@BalasrinivasCSКүн бұрын
Sir want will happen if at the end there odd size of open close stack
@codestorywithMIKКүн бұрын
If open stack is not empty, we anyways return false irrespective of openClose i even or odd. But if open stack is empty, then openClose is guaranteed to be of even size. 21:25 I have explained why openClose will always be even in size if open stack is empty. Since openClose will always be even, hence no need to check. So only checking the open stack empty will do the job. Hope that helps ❤️😇🙏
@aryansinha1818Күн бұрын
25:00
@carsworld3433Күн бұрын
hey bhaiya how can i think of important test cases for deciding the solution as such important test cases are not usually given in problem thank you
@BalasrinivasCSКүн бұрын
Hello Sir, I have doubt about approach -1 when the open-close stack is even size at end can I return true ; you didn't mention that condition in the code
@codestorywithMIKКүн бұрын
I have explained the even size thing from 21:25 I have explained why openClose will always be even in size if open stack is empty. Since openClose will always be even, hence no need to check. So only checking the open stack empty will do the job. Hope that helps ❤️😇🙏
@thefinancialdiet44582 күн бұрын
Sir please give us DSA sheet for faang prep…thankyou so much for all these videos ❤❤❤❤
@codestorywithMIK2 күн бұрын
I am in the process of completing the sheet. Will soon provide ❤️😇🙏
@thefinancialdiet44582 күн бұрын
@ sirrr pleaseeee provide usss soon….it will be a blessing for usss😭😭❤️❤️❤️
@thefinancialdiet4458Күн бұрын
@@codestorywithMIK Mik bhaiya want 2 things we the students are requesting u apka samjaya hua pura thought process dimag me jata hai even kabhi pehla consistent nhi tha apka subha motivation and then video thnku for all this but 1 apki sde sheet 2 dsa pattern recognition ispr video laao 3 for beginners to advance dsa course again ye app pr hai ki app launch karna chahta ho kuki honestly apka jesa ytber mene nhi dekha if u will for course jisme sabkuch included i will be infact bahut log course ke member hoga Again thanku if possible for u then it will be great help as u travel daily firbhi itna quality teaching content thought process salute u men 🫡
@indianengineer58022 күн бұрын
Hey MIK in case of simple parentheses check without that lock array. If we are doing forward and backward pass how we are identifying that with just count being positive there will be valid parentheses ? How count assures there is valid parentheses ? this part is confusing me
@codestorywithMIKКүн бұрын
I was waiting if someone would ask this Qn. Glad you asked. Thank you. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But remember the WHY ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@divyanshu34042 күн бұрын
if its 0 i will store both '(' and ')' in stack as pair or vector of char and will check with traditional method if anyone of it satisfy i will pop. Is this method correct?
@ShivenSingh-21Күн бұрын
Take an example ( ))) ->1010 in than case : index 0 will go to open bracket stack and index 1 will go to openClose bracket stack , so when we will encounter index 2 why will we pop out from open stack ,why not from openClose stack and if we are popping out from open bracket stack doesnt that make it illegal popping as you can only pop brackets adjacent to each other , how come close bracket at index 2 pops out locked open bracket at index 0 when you have 1 bracket in between ????
Does anyone know where else we can apply that greedy approach with a constant space solution? That approach doesn’t seem intuitive at all
@codestorywithMIKКүн бұрын
Hi Vikas, usually in balanced parentheses related problems, this 2 way pass helps in some problems. Try Leetcode - 678 ❤️ Valid Parenthesis String | 4 Detailed Approaches | Leetcode 678 | codestorywithMIK kzbin.info/www/bejne/hp_SY5t3iciqfqM
@VikasMishra-q9w17 сағат бұрын
@@codestorywithMIK Thanks Mik for clarification!
@aizad786iqbal2 күн бұрын
still thora confusion hai, ki why we need right to left traversal, and why we can't check if open is 0 then return true else return false..
@codestorywithMIKКүн бұрын
I was waiting if someone would ask this Qn. Glad you asked. One more guy asked this in the comment. Thank you for asking. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But remember the WHY ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@akarshthakur9839Күн бұрын
Bhaiya go the second approach but wasnt able to get it like why is it working because esa to hai nhi ki yaa to hum sbko open hi maan lege yaa sbko closed hi maan lege to mixed lene pdege lekin phir bhi ye work ku kr rha hai if anyone can explain it will be really helpful
@codestorywithMIKКүн бұрын
Glad you asked. One more guy asked this in the comment. Thank you for asking. Let's see this scenario : s = ") ) ( ) ) )" l = "0 1 0 1 0 0" Left to Right, open = 2 if you check that since open > 0, we return false, that will be wrong. Because this string can be made balanced. It can be made balanced as - " ( ) ( ) ( )" I hope this example helps. But remember the WHY ? When traversing the string left to right, you maintain a count of open parentheses that represent the balance of the parentheses so far. This ensures that at no point do you have more closing ')' than open '(' up to that point. However, left-to-right traversal only ensures that every prefix of the string is valid. It does not guarantee that the entire string can be balanced, especially when there are unlocked 0s (flexible positions) that can later be adjusted. Right-to-left traversal ensures that every suffix of the string is also valid, which is equally important. When going right-to-left, we track close parentheses (instead of open) to check if there are enough ) to balance the ( from the right side.
@e_sumit2 күн бұрын
😉
@gamersgame43Күн бұрын
I first tried this using bruteforce backtracking
@KishanSingh-vc3reКүн бұрын
bhaiya contests k questions
@Faith_believe_00022 күн бұрын
Sab ko batana zaroori hai aapne kiya acheive kiya hai ?
@akhilsharma392Күн бұрын
if(!open.empty() && !con.empty()){ if(open.top()>con.top()){ open.pop(); }else{ con.pop(); } } please explain while we are trying to pop for a closed one why we dont't use this condition
@priyankanagpal22072 күн бұрын
How to think about all these logic?
@codestorywithMIK2 күн бұрын
Hi there, at first it all seemed too tricky to me when I was studying all these. But after solving many such Qns, everything boils down to some pattern or generic observation. Same thing I mentioned in this video as well "---- When dealing with balanced parentheses problems, always think of using a stack. Stacks are perfect for matching opening and closing parentheses and ensuring the sequence is valid. ---- Additionally, remember that a two-way pass approach (left-to-right and right-to-left) is often useful in parentheses-related problems. It helps validate both prefixes and suffixes, ensuring global balance. This is especially helpful in problems with flexibility, like when certain characters can be treated as either ( or )." I hope this helps. Remeber, the key is solve as many Qns as possible. And whenever you observe some pattern or generic approach, always keep a note of it. because most of the time, such ways can help to solve other similar problems.
@imPriyansh772 күн бұрын
@@codestorywithMIK Thank you bhaiya
@dayashankarlakhotia49432 күн бұрын
public boolean canBeEqual(String s,String locked){ int cmin=0,cmax=0; for(int i=0;i
@pratyushpandey11452 күн бұрын
Sir i was not able to figure this question out on my own 😭😭😭
@gui-codes2 күн бұрын
same bhai. Mai bhi ek jagah stuck hogaya tha.
@wearevacationuncoverers2 күн бұрын
thoda as hint maine bhi liya then solve hogaya tha mujhse but constant space wala abhi samajh aya finally. Don't worry bro, keep practicing.
@pratyushpandey11452 күн бұрын
@@wearevacationuncoverers thnx 🙏🙏
@imPriyansh772 күн бұрын
@@gui-codes Haa bhai mere bhi logic mai mistake thi
@jewelchakraborty97172 күн бұрын
Hi Mik bhai. we can do it in a single pass itself by tweaking the indexes. Please comment if you like this. /* My Java Code */ class Solution { public boolean canBeValid(String s, String locked) { int n = s.length(); if((n & 1) != 0) return false; int o = 0; int c = 0; for(int i = 0; i < n; i++){ if(s.charAt(i) == '(' || locked.charAt(i) == '0') { o++; } else{ o--; } if(o < 0) return false; if(s.charAt(n - i - 1) == ')' || locked.charAt(n - i - 1) == '0') { c++; } else{ c--; } if(c < 0) return false; } return true; } }
@codestorywithMIK2 күн бұрын
Lovely ❤️
@AnirudhSingh-y8qКүн бұрын
Now a days you are doing very much travelling bhai ,why ?
@abhayshukla51752 күн бұрын
can anyone debug this why my code is failing only 202/258 case are passing not able to understand why not working class Solution { public: bool canBeValid(string s, string locked) { if(s.length()%2!=0) return false; stackst; bool ans=true; for(int i=0;i=unmatchedCount){ ans=true; } else ans=false; } return ans; } };
@yatri63292 күн бұрын
Itna lamba video na banao bhai ..
@codestorywithMIK2 күн бұрын
Apologies for the inconvenience. I have added pointers to the videos. So that those who are not beginners and don’t need to know entire detail can skip to main parts of the video using pointers. I usually detail more just for the sake of beginners who can benefit from the minute details. I really hope it will help. Again, apologies for the inconvenience. Hope you understand 😇❤️🙏
@wearevacationuncoverers2 күн бұрын
@@codestorywithMIK MIK please keep videos detailed always. It helps those and specially me who are of beginner level and need minute details.