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

  • @Peter-od1rm
    @Peter-od1rm Жыл бұрын

    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

    @codestorywithMIK

    Жыл бұрын

    Thank you so much 😇❤️ I have pinned your comment so that others could see ❤️❤️

  • @aws_handles

    @aws_handles

    6 ай бұрын

    Thanks to KZread for recommending this to me 🔥🔥

  • @user-ub2is4rs4x

    @user-ub2is4rs4x

    5 ай бұрын

    Now i only search in this channel for any problem. This is a rare gold mine

  • @souravjoshi2293
    @souravjoshi2293 Жыл бұрын

    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

    @codestorywithMIK

    Жыл бұрын

    Thank you so much ❤️

  • @saiky_111
    @saiky_111 Жыл бұрын

    After searching this problem, when i saw you made a video on this, my eyes lit up😊

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thank you so much ❤️❤️❤️

  • @mirdulswarup9065
    @mirdulswarup9065 Жыл бұрын

    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

    @codestorywithMIK

    Жыл бұрын

    Feedback taken Mridul. Thanks a lot for your precious words.

  • @KrishnaSingh-je8pu
    @KrishnaSingh-je8puАй бұрын

    Bhai aap kamal ke ho....kya explanation dete ho yrrr...gajab

  • @Thriftinghai
    @Thriftinghai5 ай бұрын

    This is GOLD. Best explanation over internet.

  • @nobbiesid1324
    @nobbiesid13249 ай бұрын

    Again best Explaination Thanku bhya 🥰

  • @TheMdaliazhar
    @TheMdaliazhar2 ай бұрын

    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

    @codestorywithMIK

    2 ай бұрын

    Never ever give up ❤️❤️❤️

  • @facttecher3039
    @facttecher30392 ай бұрын

    Nice explanation SIRJI.

  • @TheCurrencyNomad1
    @TheCurrencyNomad17 ай бұрын

    Meri jaan mja aa gya solution mai..kya mast smjhahya hai

  • @user-ub2is4rs4x
    @user-ub2is4rs4x5 ай бұрын

    This is nothing but a MASTERPIECE 🔥

  • @amanpahari690
    @amanpahari6904 ай бұрын

    liked ur flow in the vedio and the way of teaching is great.Thanks

  • @secretdreams201
    @secretdreams2015 ай бұрын

    Thankyou for this amazing explanation.

  • @smsyd853
    @smsyd8533 ай бұрын

    Thank you boss i just watched 20 min of your viideo and then solved it on my own.

  • @helloworld6208
    @helloworld62086 ай бұрын

    Excellent sir

  • @viveksingh_01
    @viveksingh_015 ай бұрын

    Couldn't solve it even after seeing other youtuber's explanation but after seeing your explanation I could solve it easily

  • @codestorywithMIK

    @codestorywithMIK

    5 ай бұрын

    🙏🙏❤️❤️ so glad to hear this

  • @viveksingh_01

    @viveksingh_01

    5 ай бұрын

    @@codestorywithMIK 🙏

  • @codestorywithMIK
    @codestorywithMIK Жыл бұрын

    Explanation : 3:00

  • @kunalpatil.24
    @kunalpatil.245 ай бұрын

    Thank you !

  • @prateekgirilateralentry5865
    @prateekgirilateralentry58653 ай бұрын

    Thank You Sir .

  • @Sanjaysview
    @Sanjaysview6 ай бұрын

    Excellent explanation my brother thank you so much

  • @codestorywithMIK

    @codestorywithMIK

    6 ай бұрын

    ❤️❤️❤️

  • @S3aw0lf
    @S3aw0lf5 ай бұрын

    Had to watch twice but explanation was superb as always with each minute details and understood the whole story clearly

  • @om3585
    @om35855 ай бұрын

    Salute hai bhai aapko😎

  • @vaishalisahu2598
    @vaishalisahu25985 ай бұрын

    A good teacher can make everything simple and joyful ✨ Thankyou so much sirr❤ you ended the fear of hard problems✨

  • @trayambrathore7735
    @trayambrathore77355 ай бұрын

    nice qn and good explaination

  • @ugcwithaddi
    @ugcwithaddi5 ай бұрын

    insane explanation

  • @anshumaan1024
    @anshumaan10245 ай бұрын

    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

    @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))

  • @aadarshpandit2929
    @aadarshpandit29295 ай бұрын

    wow sir so nice explanation

  • @see2672
    @see2672 Жыл бұрын

    Sir please make a video on minimum window subsequence.Thank you.

  • @gagankaushik556
    @gagankaushik5563 күн бұрын

    thnx

  • @ShivamGupta-cx3hy
    @ShivamGupta-cx3hy Жыл бұрын

    Thank You sir ☺️

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Glad i could help ❤️

  • @abhisheknandann
    @abhisheknandann10 ай бұрын

    Soothing voice+great explanation=🔥

  • @codestorywithMIK

    @codestorywithMIK

    10 ай бұрын

    Means a lot. Thank you so much 😇❤️🙏

  • @nishantdehariya5769
    @nishantdehariya57694 ай бұрын

    very nice

  • @retromonk88
    @retromonk8811 ай бұрын

    Top Tier explanation jod>>>

  • @codestorywithMIK

    @codestorywithMIK

    11 ай бұрын

    Thanks a lot ❤️😇

  • @sparshyadav9709
    @sparshyadav97093 ай бұрын

    Understood.

  • @engg.5111
    @engg.511111 ай бұрын

    Maja agyaa bro🔥🔥

  • @codestorywithMIK

    @codestorywithMIK

    11 ай бұрын

    Thank you ❤️😇

  • @pulastyadas3351
    @pulastyadas335111 ай бұрын

    Really hard made easy by your explanation… 😊😅❤please continue ❤

  • @codestorywithMIK

    @codestorywithMIK

    11 ай бұрын

    Thank you so much ❤️😇🙏

  • @pulastyadas3351

    @pulastyadas3351

    11 ай бұрын

    @@codestorywithMIK could you please cover leetcode 726 - no of atoms problem... please

  • @swasthikbhatt9833
    @swasthikbhatt9833 Жыл бұрын

    Thank you so much bro 🥰

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Thank you so much I am glad it helped 😇❤️🙏

  • @divyanshsagar
    @divyanshsagar Жыл бұрын

    nicely explained!

  • @codestorywithMIK

    @codestorywithMIK

    Жыл бұрын

    Glad it was helpful! ❤️🙏😇

  • @girikgarg8
    @girikgarg810 ай бұрын

    Nice explanation!

  • @codestorywithMIK

    @codestorywithMIK

    10 ай бұрын

    Glad it was helpful! 😇

  • @theOmKumar
    @theOmKumar5 ай бұрын

    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; } }; */

  • @k-CE-OmkarPathak
    @k-CE-OmkarPathak5 ай бұрын

    🙏🙏🙏🙏

  • @Gyan_ki_dukaan-sx6le
    @Gyan_ki_dukaan-sx6le4 ай бұрын

    awesome dude!! couldn't think it in first go.. how long did it took to devise this soln urself?

  • @codeandtalk6
    @codeandtalk65 ай бұрын

    ❤❤❤

  • @bhartendupant8859
    @bhartendupant88595 ай бұрын

  • @mirdulswarup9065
    @mirdulswarup9065 Жыл бұрын

    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

    @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. ❤

  • @sidharthdhiman4522
    @sidharthdhiman4522 Жыл бұрын

    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

    @codestorywithMIK

    Жыл бұрын

    Awesome Sidharth. ❤️❤️ Thanks a lot for sharing your idea. Would you also please share the code

  • @aws_handles
    @aws_handles6 ай бұрын

    ❤️❤️

  • @ehasah6840
    @ehasah684016 күн бұрын

    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

    @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.

  • @yashdeshmukh6191
    @yashdeshmukh61915 ай бұрын

    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

    @codestorywithMIK

    5 ай бұрын

    I’ll definitely make a video on that 🙏🙏❤️❤️

  • @user-kr7lw4yo9o
    @user-kr7lw4yo9o7 ай бұрын

    Bro what does that INT_MAX does i didnt get the last return part what are we actually checking can someone please help me

  • @user-vk7wb6hg9b
    @user-vk7wb6hg9b3 ай бұрын

    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

  • @chillkro25
    @chillkro256 ай бұрын

    Can i take queue instead of deque

  • @user-iv3jg1jn9z
    @user-iv3jg1jn9z13 күн бұрын

    Its a beautiful explaination but the logic is tough to take in

  • @HuzaifaBilal-fo7zc
    @HuzaifaBilal-fo7zc3 ай бұрын

    This solution was showing TLE in GFG so it got optimized by using array...

  • @gauravbanerjee2898
    @gauravbanerjee289810 ай бұрын

    Crystal clear explanation thanks a lot bhaiya ❤❤ but bhaiya problem leetcode pe to submit hogya but gfg pe kyu TLE mar gya 🥹

  • @codestorywithMIK

    @codestorywithMIK

    10 ай бұрын

    Thank you 😇❤️ Can you share gfg code that you are trying ?

  • @gauravbanerjee2898

    @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

    @gauravbanerjee2898

    10 ай бұрын

    @@codestorywithMIK any updates bhaiya??

  • @priyanshusingh3316
    @priyanshusingh33165 ай бұрын

    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

  • @HeetVichhivora
    @HeetVichhivora5 ай бұрын

    bhaiya amazing ,aapka linkedin ?

  • @codestorywithMIK

    @codestorywithMIK

    5 ай бұрын

    Thank you 😇 www.linkedin.com/in/mazhar-imam-khan-95a34ab3?

  • @ayushivishwakarma9101
    @ayushivishwakarma91015 ай бұрын

    how to do these type of question without watching tutorial ??

  • @surajsharma-1554
    @surajsharma-15544 ай бұрын

    ye approach gfg pe tle mar rhi hai

  • @atharvapimple9262
    @atharvapimple92625 ай бұрын

    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

  • @saiei
    @saiei5 ай бұрын

    //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

  • @jagadeeshp1163
    @jagadeeshp11638 ай бұрын

    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

  • @dayashankarlakhotia4943
    @dayashankarlakhotia49435 ай бұрын

    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); 🎉❤

  • @eron7850
    @eron78505 ай бұрын

    me after watching this explanation " Swad++ "😂

  • @aiyappamn326
    @aiyappamn32611 ай бұрын

    Explanation ka BHAGWAAN HE YE

  • @codestorywithMIK

    @codestorywithMIK

    11 ай бұрын

    I am glad my channel is helping ❤️😇🙏

  • @shabananoor9423
    @shabananoor94235 ай бұрын

    ❤❤