Minimum Window Substring | Google | Leetcode 76
This is the 5th Video of our Sliding Window Playlist. This is one of the best Qns on Sliding Window and hence the most popular one.
The interesting Problem is - "Minimum Window Substring" | Leetcode 76
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Minimum Window Substring | Leetcode 76
Company Tags : Google, Amazon, Microsoft, Codenation, FactSet, , Atlassian, MakeMyTrip, Streamoid Technologies, Media.net, Airbnb
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/minimum...
GfG Link : practice.geeksforgeeks.org/pr...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#codestorywithMIK
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear #RecursionExplained #CodingJourney #Programming101 #TechTalks #AlgorithmMastery #Recursion #Programming #Algorithm #Code #ComputerScience #SoftwareDevelopment #CodingTips #RecursiveFunctions #TechExplained #ProgrammingConcepts #CodeTutorial #LearnToCode #TechEducation #DeveloperCommunity #RecursiveThinking #ProgrammingLogic #ProblemSolving #AlgorithmDesign #CSEducation
Пікірлер: 95
Hope whoever search this question , yt recommend your solution so everyone can come to know this masterpiece, amazing , wonderful solution that you have created. Truly amazing way of explaining thanks dude to help us out in such a easy way . Wish you infinite success ❤
@codestorywithMIK
Жыл бұрын
Thank you so much 😇❤️ I have pinned your comment so that others could see ❤️❤️
@aws_handles
6 ай бұрын
Thanks to KZread for recommending this to me 🔥🔥
@user-ub2is4rs4x
5 ай бұрын
Now i only search in this channel for any problem. This is a rare gold mine
This dude is a gem. The effort you put in while explaining is amazing. The most hardworking dry run ever seen in a channel.
@codestorywithMIK
Жыл бұрын
Thank you so much ❤️
After searching this problem, when i saw you made a video on this, my eyes lit up😊
@codestorywithMIK
Жыл бұрын
Thank you so much ❤️❤️❤️
Let me say this, not every youtuber does a code along. Appreciate it sir. You have calming voice which makes understanding of problem much better XDDD. Plus you dont try to teach in english(Hindi all the way). THANKSSSS A LOTT. please dont stop making videos. Just a suggestion please discuss the time complexities also and hints of alternative solutions
@codestorywithMIK
Жыл бұрын
Feedback taken Mridul. Thanks a lot for your precious words.
Bhai aap kamal ke ho....kya explanation dete ho yrrr...gajab
This is GOLD. Best explanation over internet.
Again best Explaination Thanku bhya 🥰
I have watched multiple youtube videos before coming here and didn't understand. I was about to give up that its not my cup of tea. Now your explanation made my day. Bhai maja aa gaya. Thanks itna achcha video banane ke liye.
@codestorywithMIK
2 ай бұрын
Never ever give up ❤️❤️❤️
Nice explanation SIRJI.
Meri jaan mja aa gya solution mai..kya mast smjhahya hai
This is nothing but a MASTERPIECE 🔥
liked ur flow in the vedio and the way of teaching is great.Thanks
Thankyou for this amazing explanation.
Thank you boss i just watched 20 min of your viideo and then solved it on my own.
Excellent sir
Couldn't solve it even after seeing other youtuber's explanation but after seeing your explanation I could solve it easily
@codestorywithMIK
5 ай бұрын
🙏🙏❤️❤️ so glad to hear this
@viveksingh_01
5 ай бұрын
@@codestorywithMIK 🙏
Explanation : 3:00
Thank you !
Thank You Sir .
Excellent explanation my brother thank you so much
@codestorywithMIK
6 ай бұрын
❤️❤️❤️
Had to watch twice but explanation was superb as always with each minute details and understood the whole story clearly
Salute hai bhai aapko😎
A good teacher can make everything simple and joyful ✨ Thankyou so much sirr❤ you ended the fear of hard problems✨
nice qn and good explaination
insane explanation
bhaiya boht acha explaint kiya hai, bs TC aur SC bhi bta dete toh maza a jaata 🙂🙂 TC -> O(m+n) SC-> O(m+n) , because map will store characters of both strings
@surajsidar3280
Ай бұрын
To reduce space complexity you can only store characters of t in map. While iterating through the characters of s string you have to check whether the key exist in map or not (But TC of finding key exist or not is O(log n))
wow sir so nice explanation
Sir please make a video on minimum window subsequence.Thank you.
thnx
Thank You sir ☺️
@codestorywithMIK
Жыл бұрын
Glad i could help ❤️
Soothing voice+great explanation=🔥
@codestorywithMIK
10 ай бұрын
Means a lot. Thank you so much 😇❤️🙏
very nice
Top Tier explanation jod>>>
@codestorywithMIK
11 ай бұрын
Thanks a lot ❤️😇
Understood.
Maja agyaa bro🔥🔥
@codestorywithMIK
11 ай бұрын
Thank you ❤️😇
Really hard made easy by your explanation… 😊😅❤please continue ❤
@codestorywithMIK
11 ай бұрын
Thank you so much ❤️😇🙏
@pulastyadas3351
11 ай бұрын
@@codestorywithMIK could you please cover leetcode 726 - no of atoms problem... please
Thank you so much bro 🥰
@codestorywithMIK
Жыл бұрын
Thank you so much I am glad it helped 😇❤️🙏
nicely explained!
@codestorywithMIK
Жыл бұрын
Glad it was helpful! ❤️🙏😇
Nice explanation!
@codestorywithMIK
10 ай бұрын
Glad it was helpful! 😇
thank you for the optimised approach , i came up with this : class Solution { public: bool isEqual(vector &window){ for(int i = 0; i if (window[i] > 0){ return false; } } return true; } string minWindow(string s, string t) { if (s.size() vector count(128,0); for(auto &ch : t){ count[ch]++; } string ans = ""; int start = 0, end = 0, minSize = INT_MAX; while(end //update curr element count[s[end]]--; //shrink window while(count[ s[start] ] count[s[start++]]++; } //update valid window to ans if(end-start+1 ans = s.substr(start,end-start+1); minSize = ans.size(); } end++; } return ans; } }; */
🙏🙏🙏🙏
awesome dude!! couldn't think it in first go.. how long did it took to devise this soln urself?
❤❤❤
❤
Ek cheez please bta dijiye, if abc ki aabc hota in which a is repeating toh count characters wala jo variable hai uski length 4 hi jaati ya 3 jaati since unique characters sirf 3 hai
@codestorywithMIK
Жыл бұрын
Uski length 4 Jaati. Kyoki hume poori string 't' chase in 's' . 't' ki length 4 hai to poori 4 length Jaati. I hope I could answer your qn. Thanks a lot again for your comments. ❤
I also have another approach wehre instead you have counter make the the use of another array and keep adding characters until the m1 == target_map and if becomes equal try to remove the characters.
@codestorywithMIK
Жыл бұрын
Awesome Sidharth. ❤️❤️ Thanks a lot for sharing your idea. Would you also please share the code
❤️❤️
Amazing explanation. Thank you very much. I have a question - why did we kept track of frequencies of all characters (which are not in t string)? Don't we just need the characters in t string? I was just curious.
@vineetjadhav1785
11 күн бұрын
Yes ur Right, I thought the same way, coz storing the unwanted characters in the map also can increase space complexity and make code large.
Sir how you are so much consistent... What do you do to be so focused...? Yoga, meditation or anything! I am surprised 🤯 sir. Please if you don't mind please share your routine with me. It would be helpful.
@codestorywithMIK
5 ай бұрын
I’ll definitely make a video on that 🙏🙏❤️❤️
Bro what does that INT_MAX does i didnt get the last return part what are we actually checking can someone please help me
The same problem when I tried submitting on gfg using this solution gives TLE with 4000/5000 tc passed, please suggest me how can I optimise it more
Can i take queue instead of deque
Its a beautiful explaination but the logic is tough to take in
This solution was showing TLE in GFG so it got optimized by using array...
Crystal clear explanation thanks a lot bhaiya ❤❤ but bhaiya problem leetcode pe to submit hogya but gfg pe kyu TLE mar gya 🥹
@codestorywithMIK
10 ай бұрын
Thank you 😇❤️ Can you share gfg code that you are trying ?
@gauravbanerjee2898
10 ай бұрын
@@codestorywithMIK Yes bhaiya sure, here it is class Solution { public: //Function to find the smallest window in the string s consisting //of all the characters of string p. string smallestWindow (string s, string t) { // Your code here int n =s.length(); if(t.length()>n)return""; unordered_mapmp; for(char &ch:t){ mp[ch]++; } int requiredCount=t.length(); int i=0, j=0; int minwindowSize =INT_MAX; int start_i=0; while(j0){ requiredCount--; } mp[ch]--; while(requiredCount==0){ int curWindowSize = j-i+1; if (minwindowSize>curWindowSize){ minwindowSize = curWindowSize; start_i=i; } mp[s[i]]++; if(mp[s[i]]>0){ requiredCount++; } i++; } j++; } return minwindowSize==INT_MAX?"":s.substr(start_i,minwindowSize); } };
@gauravbanerjee2898
10 ай бұрын
@@codestorywithMIK any updates bhaiya??
complexity = O(n*2) ~ O(n) ? where n is length of s? my thinking, every element gets added and deleted/not deleted in the sliding window so for every n, at worst we have 2 operations
bhaiya amazing ,aapka linkedin ?
@codestorywithMIK
5 ай бұрын
Thank you 😇 www.linkedin.com/in/mazhar-imam-khan-95a34ab3?
how to do these type of question without watching tutorial ??
ye approach gfg pe tle mar rhi hai
Java program class Solution { public String minWindow(String s, String t) { int n=s.length(); if(t.length()>n){ return ""; } HashMap map=new HashMap(); for(char ch:t.toCharArray()){ map.put(ch,map.getOrDefault(ch,0)+1); } int required=t.length(); int i=0,j=0; int minWindow=Integer.MAX_VALUE; int start_i=0; // exploring window while(j0){ required--; } map.put(ch,map.getOrDefault(ch,0)-1); while(required==0){ // shrinking window int curr=j-i+1; if(minWindow > curr){ minWindow=curr; start_i=i; } char c=s.charAt(i); map.put(c,map.getOrDefault(c,0)+1); if(map.getOrDefault(c,0)>0){ required++; } i++; } j++; } return minWindow==Integer.MAX_VALUE? "" : s.substring(start_i,start_i+minWindow); } } Done
//kzread.info/dash/bejne/ZXaklbGPdJSrd8Y.html //we will use map on t to check if we need those letters or not, //we will use the concept of sliding window //we need to make user that all the eleemnts of t r present in s so we will use cound required that will be the length of the t //ur i and j will be at the benginging, j will go forward if ur count required is >1 //ur i will move forward if ur count required
def minWindow(self, s: str, t: str) -> str: d={} count=0 req_count=len(t) n=len(s) start=0 min_size=inf for i in range(len(t)): d[t[i]]=d.get(t[i],0)+1 i=0 for j in range(len(s)): ch=s[j] if ch in d and d[ch]>0: req_count-=1 d[ch]=d.get(ch,0)-1 while(req_count==0): # shrink if j-i+1
public String minLength (String s,String t){ int[]cnt=new int[128]; int req=t.length(),left=-1,minLength=s.length()+1; for(char c:t.toCharArray()) ++cnt[c]; for(int l=0,r=0;r=0) --req; while(req==0){ if(r-l+10) ++req; } } return left==-1?" ":s.substring(left,left+minLength); } tc=(m+n);m=t.length,n=s.length, sc=(m); 🎉❤
me after watching this explanation " Swad++ "😂
Explanation ka BHAGWAAN HE YE
@codestorywithMIK
11 ай бұрын
I am glad my channel is helping ❤️😇🙏
❤❤