Minimum Window Substring | Sliding Window | LeetCode
Ғылым және технология
Minimum window substring is a sliding window problem asked at Facebook, Amazon, Microsoft, Lyft, Google, LinkedIn, Apple, and Bloomberg. This problem is a hard problem that involves the use of several pointer and sliding window algorithm knowledge.
Check out my interview prep platform for learning the patterns!
📢 Interview Prep Platform: algoswithmichael.com
🔗 Social 🔗
🎧 Join the community Discord: / discord
💰 Support me on Patreon: / michaelmuinos
🔗Follow me on LinkedIn: / michael-muinos
📂Follow me on Github: github.com/MichaelMuinos
⭐️ Timestamps ⭐️
00:00 - Intro
00:09 - Problem Overview
01:29 - Algorithm Walkthrough
11:24 - Code Walkthrough
16:51 - Time & Space Complexity
Пікірлер: 95
I don’t usually comment but I want you to know these are very helpful, well explained, and entertaining! Thanks man.
@AlgosWithMichael
3 жыл бұрын
Thank you Chris! I'm not much of a commenter either when I am on KZread as a viewer either haha so I appreciate that
Cat !! The coder. Thank you catty for such a wonderful explanation
I like the way you explain using algorithm walkthrough before coding (the coding part becomes naturally understandable since your first visual explanation is clear). Thumb smashed.
Wow can't believe this cat is solving LC hard problems! Purrfect interviewee.
@AlgosWithMichael
3 жыл бұрын
Haha yea he is a LeetCode master
I really like the visual effects you have implemented, not a lot of other KZreadrs have this
@AlgosWithMichael
2 жыл бұрын
Thank you!
Well done. I like that you spoke clearly, slowly and methodically. A lot of other similar types of videos have the narrator jumping around and explaining the solution on the fly. I really liked your intentional approach and how you visualized everything neatly.
Very clear explanation.. Actually 2 days back I saw this question on leetcode and was searching your channel to find the video... U read my mind.. Thanks a lot...
@AlgosWithMichael
3 жыл бұрын
Haha that is awesome, glad it was helpful
for harder problems we come to Michael
Thanks for the upload
very informative video thank you Michael
Greatest explanation and demonstration on sliding window!
@AlgosWithMichael
3 жыл бұрын
Thank you!
Awesome Explanation!! Thanks
Great Video Man!
This was really helpful! I tried different approaches, but couldn't solve it. A+ for editing. I know how long editing takes and sometimes it's hard. Thanks for step by step explanation. Keep up the good work!! 👍
@AlgosWithMichael
2 жыл бұрын
I really appreciate that
Great explanation thanks! Loved the cat part :D
@AlgosWithMichael
3 жыл бұрын
Thank you very much! best comment
U xplained it in a trivial way !!keep up the good work🙌
@AlgosWithMichael
2 жыл бұрын
Thank you so much 😀
Thank you, you made my day!
Liked and subscribed. Well-informative video, my applause.
@AlgosWithMichael
2 жыл бұрын
Thank you!
thank you so much!!! great explaination
Great video. Thanks for the content
@AlgosWithMichael
3 жыл бұрын
My pleasure!
That's understable. Thankyou
new subscriber you explain very well
Loved it.. Subscribed!
@AlgosWithMichael
3 жыл бұрын
Awesome! Thank you!
Honestly saying, I sighed when you said the most difficult to digest part of the algo is when we shrink the window and start incrementing when we find the characters in the map. You were right. Now i get the whole crux of the algorithm. This question was asked in Codenation(trilogy Innovation)
@AlgosWithMichael
2 жыл бұрын
Yeah it is pretty hard to conceptualize, looking at an animated example really helped
@ShashankRustagiCSE
2 жыл бұрын
@@AlgosWithMichael if you are on LinkedIn, please drop me your id
super helpful, first time comment in youtube
glad i found ur channel
best explanation you can fi0nd on youtube for this problem . Great job .
@AlgosWithMichael
3 жыл бұрын
Thank you!
i subscribed because of your cat 😁 , great explanation
@AlgosWithMichael
3 жыл бұрын
Thank you!
Such a good video.
@AlgosWithMichael
2 жыл бұрын
Ayy thank you!
Purrfect!
You are always amazing AF.
@AlgosWithMichael
2 жыл бұрын
Haha I appreciate that
Thank you.
I was totally distracted by your cat lol
@AlgosWithMichael
3 жыл бұрын
He wouldn't move when I was about to film, so he had to do it :p
Thank you very much! Could you talk about some design problems? like LRU
@AlgosWithMichael
3 жыл бұрын
Great suggestion!
where did you get the sound clip for the error?
@7:10 around, why did you increase only count of A by 1 in the hasmap? why not other elements?
Coolest Explaination
Great Job Mike!! If you share the code . it will be more helpful.
The smartest cat on the internet fasho 🙂 lol
There is a nested while(), why is that not accounting for n^2 complexity ? Can anyone pls help me with that !
@AlgosWithMichael
3 жыл бұрын
Yea I understand why that is confusing. The while loop is moving our 2nd pointer to in the worst case touch each element one time. So in other words in the worst case, each pointer will touch each node 1 time making the time complexity (n + n) which is just n. Hope that makes sense.
Best explanation! But HOLY it's difficult haha
You said we move i pointer forward to get rid of the useless characters from the prefix of our substring then why do we incremented the count at the 0th index which is character A and it should be present in the final answer ???
I got this as a coding challenge and failed it :( thank you if I ever encounter this I will be prepared now.
If the string T was "ABBC" shouldn't the count be 4? map.size() would be 3, right?
@AlgosWithMichael
3 жыл бұрын
The count is the number of unique characters, so in that example it would still be 3.
The hard part of this problem for me was the recognizing and implementing backtracking optimization... which turns out can be done easily with a count variable haha
@AlgosWithMichael
2 жыл бұрын
Haha yea. It is a challenging problem for sure
Simply and well put explanation. Thanks
Small correction. I think you meant to say, space complexity is O(M) not O(N). (The length of string T is M)
@AlgosWithMichael
3 жыл бұрын
Yea you are right haha, thanks for pointing that out
Nice cat
nyc code kitty
I have a question: do we have to face coding interview with experience level 18 years if someone is already working as architect. ? Which companies may do that?
i just cant take my eyese off from that cat
correction: min length is j - i + 1
I didn't like that the first window size you gave is incorrect, ADOBEC is not 5 length, but 6! , I understand what you're doing but it seems strange to me.
its not working fine in below test case s = "abc" ; t = "b" ;
how come ur were not visible to me these day man , please when got time do dp problems
This doesn't work if you have t containing multiple same characters. Even if t = "aabc", this algorithm still returns "banc"
This fails for case where s=aa and t=aa
Its failing for the inputs as s = "aa" & t ="aa"
@shreyaprajapati969
3 жыл бұрын
needs to change on line 20: map.get(endChar) >= 0
@ruhigarga9542
2 жыл бұрын
Instead of initializing count = map.size(); you need to initialize count = t.Length();
@gunahawk6893
Жыл бұрын
@@ruhigarga9542 +1
why is 1,6 a valid substring in your video at 7:28 ? it does not contain any 'A'
@gunahawk6893
Жыл бұрын
6-1 , 1-1
Quite confusing on updating minLength
Who's here from Daily Question 2/3/24? :)
remove lyft from your list!! 😉
I wanna have 3 copies of that cat. I wanna swallow the first one like a pill, lick the second one for years to come, and just pet the third one for about 12 hours a day. Good explanation, too.
@AM-nv4ol
Жыл бұрын
i'm calling the police
For time complexity, you say N is length of string S and M is length of string T. For space complexity, you say N is length of string T. Was this a mistake? Why not keep the variable names consistent across time and space complexity? Thanks for the great video, enjoyed watching.
@AlgosWithMichael
3 жыл бұрын
Yea good point. I guess it is habit for me to N and M for time and space complexity explanations