Hi guys, please don’t worry if this qn seemed very hard. Actually this is based on Partition DP pattern. I didn’t mention this because i have not yet taught it in my channel. In my DP concepts playlist I will cover these topics. Dont worry, when I cover that topic, i will revisit this for sure and will also cover bottom up Thank you all ❤
@venkatarohitpotnuru385 ай бұрын
bhaiyya please complete this topic
@AlishaKhan-ww3io Жыл бұрын
All the debates are over now. This guy is the ultimate best tutor of DSA on KZbin. Hats off
@aadil4236 Жыл бұрын
Very Good explanation. many teachers put effort on solution, but you put effort on the explanation and that is why it was so good. I really understood the question and the solution with your explanation. the explanation was very good! keep it up bro!
@codestorywithMIK Жыл бұрын
It means a lot. Thank you so much ❤️🙏
@thekindspill Жыл бұрын
💯
@AlishaKhan-ww3io Жыл бұрын
totally agree . This is a legit channel
@ugcwithaddi Жыл бұрын
++
@thekindspill Жыл бұрын
You are the only guy who put all the efforts into the explanation. Code to fir humlog karlte hain. Watched some other videos since morning and all were just copy pasting the code without clear explanation. You are the best♥
@rohan87583 ай бұрын
Very very hardest question till now that i encounter in DP while i have solved over 450+ problems including 65% medium & 13% hard problems then also to think in the direction of question solution is not that much easy to me without @Mazhar Imran khan bhaiyan, hats off to you!
@sonumondal9376 Жыл бұрын
First time a teacher making us realise it's okk that you can't do and this one question can't judge your ability ❤❤❤❤❤❤❤❤ really thanks from heart sir becoz i am among those who got demotivated after not able to solve ❤❤ thanks sir
@codestorywithMIK Жыл бұрын
Thank you so much for watching ❤️😇
@sauravchandra103 ай бұрын
I had seen this video once in 2023 when I came across this question for the first time and it made sense then. Now watching it again in 2024 when I came across this question as a leetcode daily problem. I wasn't able to recall the approach I had taken back then and had to watch the entire video. Not sure if I will be able to solve this if I encounter this problem again. Such is the difficulty of this problem, or my lack of understanding.
@ugcwithaddi Жыл бұрын
Literally the only video on youtube which explain this question with clarity 🙌👌🏻
@wearevacationuncoverers Жыл бұрын
Koi itna acha kaise explain kar sakta hai yaar. I am short of words to describe his skill of teaching. L.E.G.E.N.D.DDDDDDDDDDDDDDDDDDD 💯
@codestorywithMIK Жыл бұрын
A very very similar qn which can be solved using same code asked in CISCO Online Assessment few days ago - leetcode.com/problems/remove-boxes/
@harshit68713 ай бұрын
This video is a game-changer! 🌟 The way you teach DSA is simply amazing. I struggled to understand the question before, but your clear explanations and examples made everything click. You’re truly one of the best teachers out there. Thank you for making such helpful content!
@codestorywithMIK3 ай бұрын
🙏❤️ This means a lot to me
@AmarjeetKumar-to9ub3 ай бұрын
No doubt :)
@password47403 Жыл бұрын
Beyond mere explanation, I appreciate how you've made it this intuitive! Thanks for the motivation, it was much needed! Keep up the good work sir!
@codestorywithMIK Жыл бұрын
. Please note that, This topic is going to come with scratch in my DP concepts playlist. Actually this problem is based on partition dp pattern. I didn’t mention because i have not yet taught it in my channel. I promise i will revisit this qn when I teach Partition dp and will solve this qn again with 1) Recursion + memo 2) Bottom up ❤️❤️❤️
@souravjoshi2293 Жыл бұрын
you are a legend. The effort you put in explanation and intuition building is unmatchable
@mayankraj47633 ай бұрын
Hello.. Thank you for great explanation. Your explanation never made me feel it is a hard problem. However I would like to add something: We don't need an extra if (at line 17 of your code) because we are adding the equivalent if at line 10. Open for any criticism or suggestion. Thanks.
@nitinbhattacharyya8784 Жыл бұрын
Aap bhagwan ho. Mai isi question ka solution samajhne ki koshish kar rha tha aur aapne daal diya.
@codestorywithMIK Жыл бұрын
Thank you so much for watching 😇❤️
@rohitshah8904 Жыл бұрын
Was unable to understand the question even ....now it's clear
@codestorywithMIK Жыл бұрын
Thank you so much for watching ❤️😇
@mangeshshikrodkar61923 ай бұрын
ap GOD admi ho. or in new terms GOAT (greatest of all times :) )
@sauravbiswajit8091 Жыл бұрын
Greaaaaaattttt sir....not even to understand the question in first go 😢...u r an absolute great teacher sir
@codestorywithMIK Жыл бұрын
Thanks a lot. Means so much 🙏❤️😇
@anonght21213 ай бұрын
Bhaiya please continue with your dp concepts playlist, it's been incredibly helpful !
@uvs_6032 Жыл бұрын
Yeah this one is quite tricky, didnt even see the repeating subproblems at first.
@iamnoob75932 ай бұрын
this is also valid right -> 1 + solve(i,j-1) + solve(j+1,r)
@thetoxicguy47833 ай бұрын
Please MIK don't stop making these videos🩷
@minutelearn76633 ай бұрын
sir whenever I feel stuck u saved me
@anuppatankar4294 Жыл бұрын
Great Explanation as always 👌🏻
@codestorywithMIK Жыл бұрын
Thank you so much. Also, Please see my pinned comment 😇🙏❤️
@anuppatankar4294 Жыл бұрын
Yes 👍🏻@@codestorywithMIK
@suvamroy620510 ай бұрын
Couldnt we do 1+(i,j-1)+(j+1,r) ? if (j+1 out of bound then return 0)
@AishwaryaAishwarya-e4l Жыл бұрын
wow !!! thankyou sir !!! i really understooooood in one go!!! got confidence !! thankyou again
@codestorywithMIK Жыл бұрын
Thank you 🙏😇
@mohithadiyal6083 Жыл бұрын
Best explanation i could ever find
@codestorywithMIK Жыл бұрын
Means a lot 😇❤️
@dayashankarlakhotia4943 Жыл бұрын
Superb explanations til now going top
@codestorywithMIK Жыл бұрын
Thank you so much 🙏❤️
@Cicada-hq6yp Жыл бұрын
Sir isme lalach waale approach mein hamne solve(j,r) pe call kyu kiya jabki mujhe pata hai ki jo j pe character hai usi ko print kar raha hu main (as in ki pehle hi maine 'a' ke continuously character print kiye hai toh usime include kar lunga ) toh solve(j+1,r) ki cal nahi karenge ham?
@itskaaryan73 ай бұрын
because ham log uska cost pehle add nhi kiye hai so jo aage rahega usme se uska cost add kar lenge thats why we have started from j and not j+1 , becaue j par whi char hai jo l par tha aur jiska cost we havent added will be added when we do a recursive call for solve(j ,r). Hope this helps !!
@dhairyachauhan6622 Жыл бұрын
very nice explaination just thinking the lalach wala tareeka is extremely hard. Thought i understand this one now but still i am not confident enough about the fact, that i will be able to solve similar questions, i guess the only thing in hand is practice.
@codestorywithMIK Жыл бұрын
Dont worry, In my DP concepts playlist I will cover these topics. This is actually based on Partition DP. Dont worry, when I cover that topic, i will revisit this for sure and will also cover bottom up
@aws_handles3 ай бұрын
Legend ho sir aap
@prateekmohanty8315 Жыл бұрын
Amazing explanation bhaiya , the question is very good and particition dp as it is a difficult topic , but you made this question look very much intuitive. Eagerly waiting for your particition dp playlist . Kudos to you
@codestorywithMIK Жыл бұрын
Thank you so much. Partition dp coming soon in my DP Concepts and Qns playlist ❤️❤️❤️
@Raj10185 Жыл бұрын
Its a partation dp hard problem :- my implmentation is :- int n ; int dp[102][102]; int solve(int i , int j , string s) { //base case if(i==j) //length 1 string only 1 turn need return 1; if(dp[i][j] != -1) return dp[i][j]; // for all other cases we need to do the partataion // This is question of partation dp => aditya verma explanation int minturn = INT_MAX; for(int k = i ; k < j ; k++) { minturn = min(minturn , solve(i,k,s) + solve(k+1,j,s)); } // 1 extra case is there if first and last char matches i.e i and j matches then // minturn will be reduce by 1 if(s[i]==s[j]) return dp[i][j] = minturn-1; return dp[i][j] = minturn; } int strangePrinter(string s) { n = s.size(); if(n==1) return 1; memset(dp,-1,sizeof(dp)); return solve(0,n-1,s);
@codestorywithMIK Жыл бұрын
Indeed ❤️
@rev_krakken703 ай бұрын
Was a classic mcm type question
@pranaymacharla6083 Жыл бұрын
explain leetcode contest hard problems too , your explainations is very intuitive
@codestorywithMIK Жыл бұрын
Sure thing ❤️😇 Also, Please see my pinned comment 😇🙏❤️
@factsmadeiteasy9943 Жыл бұрын
Suggetion: Start making videos on Contest Questions,next day after contest is over .
@dipalisharma46823 ай бұрын
I will make it easy hits different ❤❤
@ganeshjaggineni40973 ай бұрын
NICE SUPER EXCELLENT MOTIVATED
@Danish-saifi1 Жыл бұрын
Aaj ke leetcode contest ka 4th and 3rd questions ka bhi video bna do sir
@YashSinghal Жыл бұрын
dp questions are always interesting
@codestorywithMIK Жыл бұрын
Indeed. Please note that, This topic is going to come with scratch in my DP concepts playlist. Actually this problem is based on partition dp pattern. I didn’t mention because i have not yet taught it in my channel. I promise i will revisit this qn when I teach Partition dp and will solve this qn again with 1) Recursion + memo 2) Bottom up ❤️❤️❤️
@YashSinghal Жыл бұрын
@@codestorywithMIK thank you. I have started watching the dp playlist 😄
@codestorywithMIK Жыл бұрын
❤️❤️❤️
@YashSinghal3 ай бұрын
back to this amazing Q and video after 1 year!!
@xiaoshen194 Жыл бұрын
Mere codeforces' expert friend ne ye ques khud se 40 min ke under solve kr liya😢
@vineetkumarmotwani474 Жыл бұрын
btw I did a slight optimisation in ur code, this one: int greedy = INT_MAX; for(int j=i; j
@codestorywithMIK Жыл бұрын
Hi there, I know why many people could solve this in 30-40 minutes. Because they are already aware about Partition DP. Please see my pinned comment 😇🙏❤️ I promise you will be able to solve this. Just give me some time to complete Partition dp in my playlist 😇🙏
@AyushRaj-we2og Жыл бұрын
Hey MIK Bhaiya! Are LeetCode questions with a lot of downvotes worth solving?
@aadil4236 Жыл бұрын
I have the same question
@AlishaKhan-ww3io Жыл бұрын
Same qn
@thekindspill Жыл бұрын
Same qn bhai
@codestorywithMIK Жыл бұрын
Generally qns get dislikes because of poor problem statement Dont worry, in interviews, they clear the qns well and explain well if you dont get it. You can check for explanation in discuss sections else leave the qn if its too badly explained
@gui-codes4 ай бұрын
Man you are the best.
@iamnoob75932 ай бұрын
Thanks a ton
@aizad786iqbal3 ай бұрын
amazing, can you give an example jisme basic se better result aayega ? also please make the video on other approaches, thank you...
@shraddhamali213 ай бұрын
Excellent Explanation!! Thank you so much...but I didn't understand one part ....in lalach vali adjustment we can print last "ba" but what about the first "a" how it will get printed ..please explain
@AnkitKumar-ge3jn3 ай бұрын
it will get printed when you print the last a... you are smart enough to print all the previous 'a' to the current one
@shraddhamali213 ай бұрын
@@AnkitKumar-ge3jn Ok thank you...
@challengeAceiver3 ай бұрын
Bhaiya samajh to aaya but jab thoda bada string le raha hu 5 length ki then uspe dry run karne mein kafi problem aa rhi hai aap pls bade test case pe run karke bata sakte ho kya? Kafi help hojayegi
@ashmitpatel4829 Жыл бұрын
Sir remove boxes leetcode 546 question was asked in OA in cisco It was very similar to this .Plz try to upload its solution. Ty for all your efforts sir❤
@codestorywithMIK Жыл бұрын
Sure thing. Noted ❤️❤️❤️
@Rajat_maurya Жыл бұрын
How you are so good man❤
@codestorywithMIK Жыл бұрын
It means a lot Rajat. Thank you so much 🙏❤️
@masoomyf3 ай бұрын
today's question...
@pankajdewangan4137 Жыл бұрын
very good sir
@codestorywithMIK Жыл бұрын
Thank you so much for watching ❤️😇
@Anand14527 Жыл бұрын
Great
@pallavivarshney79729 ай бұрын
please make a video on solving remove boxes question.
@PatelIndra3 ай бұрын
Hi sir in this video for lalach case you have mentioned that we are tacking solve(i, j-1, s) + solve (j, r, s) instead of 1 + solve(i, j-1, s) + solve(j+1, r, s) so as per the your point of view both are same but if I take second one instead of first one than I am not getting right answer please explain me if anyone know about it
@shudhanshujaiswal3022 Жыл бұрын
Thanks man!
@codestorywithMIK Жыл бұрын
Thank you so much for watching 🙏❤️
@codingedtech Жыл бұрын
super
@kuchbhi7811 Жыл бұрын
Hello sir ,mujhe leetcode k problems video dekhne k baad hi smjh aata h . Data Structure implementation ho jta h but logic kabhi nhi aa ta h problem solving k liye. Uske liye kya karu please help
@codestorywithMIK Жыл бұрын
Hi there, Please cover DSA topic by topic. Fix one topic for a day, study it, solve easy qns, then medium qns. Skip hard as of now until you have practices easy mediums in a good number.
@floatingpoint7629 Жыл бұрын
Thanks for the explanation. dimagh kharab kar diya tha is question nay and whats the difference between matric chain multiplication and partioning dp ?
@codestorywithMIK Жыл бұрын
Both refer to same pattern. I will cover this in full detail in my DP concepts playlist. And I am gonna revisit this qn again that time with recur memo as well as bottom up
@floatingpoint7629 Жыл бұрын
@@codestorywithMIK super. looking forward to it.
@codeandtalk6 Жыл бұрын
❤❤
@nitinbhattacharyya8784 Жыл бұрын
Bhaiya leetcode 1330 par bhi agar ho sake video bana dijiyega. Math aur greedy hai solution ekdum samajh nahi aa rha
@codestorywithMIK Жыл бұрын
Noted. Will cover soon
@10minutes_csАй бұрын
15:26 , why are we not taking (j+1,r), to handle this .
@it047_prakhar83 ай бұрын
i am the best❤
@asutoshbikun3 ай бұрын
Sir pls do contest qns also
@codestorywithMIK3 ай бұрын
This week’s Sunday Contest Qn-1 and 4 kzbin.info/www/bejne/aJWUcn99bdyqesUsi=fAMNs8g1YmKgDe4e ❤️
@kishan.17 Жыл бұрын
bhaiya is cp necessory or good dsa enough for good compinies??.
@SanskarGarg Жыл бұрын
Yes , to clear Online assessment independently you should do.
@codestorywithMIK Жыл бұрын
I am observing that in some OAs, tough qns are being asked. In such cases cp help. But many of my juniors and friends gave Amazon , Microsoft OAs and leetcode medium hard were enough for those qns. The main motive should be to first get clarity in each and every topic. Then start solving qns on those topics from easy -> Medium -> Hard -> expert
@331sachinkiragi83 ай бұрын
From where did YOU learnt this all?
@swapnilwalave11353 ай бұрын
hey anyoune can explain how tbgtgb string take 4 step bcz i dry run think on it many times it take 5 step
@future_engineer0203 ай бұрын
t(0,0)+bbbbb(1,5)+ggg(2,4)+t(3,3)
@future_engineer0203 ай бұрын
@swapnilwalave1135 in the bracket, I have written (starting pos, ending pos) hope this helps
@swapnilwalave11353 ай бұрын
Thank you
@Abhi_008 Жыл бұрын
This solution could be better.... class Solution { int solveRec(int i, int j, string& s) { if(i == j) return 1; int ans = INT_MAX; for(int k = i; k < j; k++) { ans = min(ans, solveRec(i, k, s) + solveRec(k+1, j, s)); } if(s[i] == s[j]) ans = ans - 1; return ans; } int solveRec_Mem(int i, int j, string& s, vector& dp) { if(i == j) return 1; if(dp[i][j] != -1) return dp[i][j]; int ans = INT_MAX; for(int k = i; k < j; k++) { ans = min(ans, solveRec_Mem(i, k, s, dp) + solveRec_Mem(k+1, j, s, dp)); } return dp[i][j] = (s[i]==s[j]) ? ans - 1 : ans; } public: int strangePrinter(string s) { int n = s.length(); // Recursive Approach // return solveRec(0, n - 1, s); // Recursion + Memoization vector dp(n+1, vector(n+1, -1)); return solveRec_Mem(0, n - 1, s, dp); } };
@codestorywithMIK Жыл бұрын
Thank you so much for sharing ❤️😇
@vikneshcs4824Ай бұрын
How parition in 1,2,3,4 would result in ans 1,2,3,4 fir abaaaaa
@ashutosh61290 Жыл бұрын
bhaiya aapka naam kya hai??
@vishalkurve933 ай бұрын
Can anyone help me memoize this recursive code.It is working but it i sgiving TLE at 17th test case. Please help me. class Solution { public: int solve(int i,string temp,string s) { if(s==temp) return 0; if(i>=s.length()) { return 1000000; } int minoperations=1000000; for(int start =i;start
@GajendraGour-of9it3 ай бұрын
anyone solve this problem in java
@AnandKumar-kz3ls Жыл бұрын
i dont have enough brain cells for this question 😢
@codestorywithMIK Жыл бұрын
Hello Anand, Please see my pinned comment 😇🙏❤️
@RIYAGUPTA-qi1dw Жыл бұрын
bhaiya seriously aaj ka question bilkul samajh nhi aaya🥲🥲🥲🥲
@wearevacationuncoverers Жыл бұрын
Same. I could only understand after watching this video 😢
@codestorywithMIK Жыл бұрын
Dont worry, In my DP concepts playlist I will cover these topics. This is actually based on Partition DP. Dont worry, when I cover that topic, i will revisit this for sure and will also cover bottom up
@RIYAGUPTA-qi1dw Жыл бұрын
@@codestorywithMIK thanks bhaiya
@ManojKrVerma-vw4dx Жыл бұрын
For me it was difficult 😢😢
@codestorywithMIK Жыл бұрын
Dont worry, In my DP concepts playlist I will cover these topics. This is actually based on Partition DP. Dont worry, when I cover that topic, i will revisit this for sure and will also cover bottom up
@sourav_22_11 Жыл бұрын
thnx a lot brother , plz upload hard dp coders as much as possible
@codestorywithMIK Жыл бұрын
Sure thing Thank you so much for watching ❤️😇
@GauravSingh-v4p Жыл бұрын
yaar aaj k samjh nhi aaya
@codestorywithMIK Жыл бұрын
Hi there, Apologies if it was not much clear. I will definitely improve more on that. However would you kindly share which part exactly you couldn’t get ?
@GauravSingh-v4p Жыл бұрын
@@codestorywithMIK i am not able to understand the explanations like how i,j ,l,r realated don't know. not able to make image of the solution or explanation in my mind
@MounikaEMB Жыл бұрын
same here🥲
@codestorywithMIK Жыл бұрын
Noted guys I really appreciate your feedback. Please don’t worry. This topic is going to come with scratch in my DP concepts playlist. Actually this problem is based on partition dp pattern. I didn’t mention because i have not yet taught it in my channel. I promise i will revisit this qn when I teach Partition dp and will solve this qn again with 1) Recursion + memo 2) Bottom up ❤️❤️❤️
@yatri6329 Жыл бұрын
@@codestorywithMIK thanks sir ♥️♥️
@rode_atharva3 ай бұрын
agar samaj nahi ata na to me is printer ko kude me fek deta yarr sachme. kya vahiyat printer hai😂