39:45 when MIK bro said "code bht aacche likhe hue h but pata nahi explain kyun nahi karte h..." Bhai dimaag lagta h na usme varna to sab COPY + PASTE + MODIFICATION hi h and looking at the views on this video you can see People actually m khaan intrested h 🤷 They just don't want to spend some time actually UNDERSTANDING the stuff (maybe Interview m qstn poochne vaale ko khudd itna nahi pata hota 🤣) bus cramming h or phir kehete h // bhai qstns nahi bante humse 👀 MIK bhai this is actually the USP of you and this channel that jaise aapne samjha vaisa khudd aap apni videos m as it is utaar detee ho so it's my humble equest to you NEVER EVER feel ki log dekh nahi rahe h yaa views nahi aate aisi videos p Humm jaise kucch pagal bacche hue h ab bhi jo actually m samajh k karna or seekhna chahhte h...🙏
bhaiya ,agar subarrays whose summation is zero vale ques. mein agar subarrays bhi return karne bole ques. mein toh map mein index bhi store karna padega ki kab kab dekha ?? ya fir kuch aur??
Nice Explanation. But I am not sure whats the time complexity. If input is something like "ababababababababababababababababababab..............." the this is n^2. Correct me if i am wrong?
class Solution { public: long long beautifulSubstrings(string s, int k) { int n = s.length(); unordered_mapmp; mp[0].push_back(-1); long long pre = 0; long long ans = 0; for(int i=0;i
result += k Ensures that we are considering all such substrings. This is exactly same as how we calculate “Find subarray count having sum 0” , in that also we don’t do result++. Just run this example with result++ and you will realise what cases we will miss. Example : s = “abba” , k = 1
@@codestorywithMIK But, here we are mapping k with count of vowels, and the count of vowels will always increase as we move in the string so k should always be 1 ig
@@ashish2438 @codestorywithMIK Yes you are also right that since vow count always increase so it will work fine in doing ++ans also, but the case he want to tell about is like if we got same count let say 2 2 2 2 in vector we have 4 enteries if we have take map, but if we take map for the above thing it would be mp[pref][2] = 4 jo just in (order of 1) we will get this and our iteration will get reduces just by doing +k , here 4 count is stored in k. in the problem the thing is we will never get this case because vowel count is always on increasing we can get same (vow- con) but for that vow is always increasing so ++ans also work fine but since he explain the prior problem where we are counting subarray with sum 0 now assume what i explain above that case 2, 2, 2, 2 if we not do +k in this case, we get wrong answer becuase 2 enteires are 4 but doing ++ only 1 subarray is counted, with reference do this case + k is very imp and also this is the reason we use map of map because same thing can be done my map of vector also since we dont want to iterate for 2 2 2 2 again so he used map of map but again this case will never come so using map of vector also works fine. I hope you understand the case where +k is used.
Sir do we need to memorize dsa question daily. I mean i understand this solution but do we need to revise such question whose intuition we not get directly
Hi there, Actually these Qns are related to many others Qns in past. Most of the people who are able to solve it during contests have solved many many many such qns and it helps them to relate and come-out with the approach to solve Qns like these. So always remember, it will come with a lot of practice and solving lots of problems. If we start solving lots of HARD and Medium problems, then you will start seeing that contest hard problems are variations of such (mostly) . for example: this week Sunday contest Qn - 4 , it was an amazing followup of already solved qn in past in my channel. This is just one example and it happens mostly to all other hard problems.
39:45 when MIK bro said "code bht aacche likhe hue h but pata nahi explain kyun nahi karte h..." Bhai dimaag lagta h na usme varna to sab COPY + PASTE + MODIFICATION hi h and looking at the views on this video you can see People actually m khaan intrested h 🤷
They just don't want to spend some time actually UNDERSTANDING the stuff (maybe Interview m qstn poochne vaale ko khudd itna nahi pata hota 🤣) bus cramming h or phir kehete h // bhai qstns nahi bante humse 👀
MIK bhai this is actually the USP of you and this channel that jaise aapne samjha vaisa khudd aap apni videos m as it is utaar detee ho so it's my humble equest to you NEVER EVER feel ki log dekh nahi rahe h yaa views nahi aate aisi videos p
Humm jaise kucch pagal bacche hue h ab bhi jo actually m samajh k karna or seekhna chahhte h...🙏
This comment made my day.
Thank you so much 🙏❤️😇
(Took screenshot of this comment) 😇❤️
@@codestorywithMIK ❤
totally agree man.
💯
@@codestorywithMIK that,s why i watch all the video for better concept understanding🥰🥰🥰
Your dedication for teaching is on another level 🔥🔥. Thank you bhaiya.
No one can explain like you. I think this is the only channel which deals with Hard problems like this and make them easy.
I think no one on RUclips or no Paid course of so called famous RUclipsrs can explain like this. Hats off to this guy 🎩
hats off to your dedication
Thanks for the simple explanation bhai.
Always welcome 😇❤️
koi itna acha kaise parha sakta hai bhai. Top level content hai yaha free me.
Bhaiya If possible leetcode contests ke hard questions ke videos bana diya kro naa aise hee ❤️
Noted 😇🙏
very easy explanantion, thanks a lot
keep going brother
one of the great explainer
Thanks a lot 🙏😇
no one can teach like this legend
worth to watch 🎯🎯🎯🎯
Crystal clear explanation beyond expectations
Thank you so much 🙏😇
Just two words - Awesome Explanation! (btw, first time viewer).
Welcome to my channel.
Thank you so much 🙏😇
@@codestorywithMIK Keep posting such amazing explanations. Will be a regular viewer now.
Bhaiya aap contest ke bhi solution dala karo atleast 3rd ,4th to dala hi karo isse kafi help hogi hmlogo ki .
so beautiful so elegant just looking like a wow😀😀😀
Thank you 😅
Hats off to your dedication.
I can't believe I am able to finally understand such Hard Qns easily. Thanks to this legend.
big shoutout, wonderful
Thank you so much. Means a lot 😇🙏
Sir Charan kahan h aapke. Tough question ko halwa bna dya aapne.❤❤❤❤
True legend sir
keep posting man
worth watching 52 minutes ✨✨
Thank you so much ❤️🙏
amazing ...
Thank you 😇🙏
Can we take unordered_map
Please start a series on segment tree. Love from Pakistan
Great explanation 👌🏻
Glad you liked it 😇🙏❤️
Thank you ❤❤❤❤❤❤❤
You are so welcome 😇❤️
What would be the time complexity?
What exactly will be its time complexity? I assume it to be O(n*max(occurrences_of_vowels_across_map))
Can it be simplified?
Sir I have requested to u please make a video on leetcode 1478 Allocate mailboxes
Let me check soon
good explanation mind blowing explanation. also explain leetcode 2945
Let me check soon.
bhaiya ,agar subarrays whose summation is zero vale ques. mein agar subarrays bhi return karne bole ques. mein toh map mein index bhi store karna padega ki kab kab dekha ?? ya fir kuch aur??
Correct you should store indices for subarray printing.
Nice Explanation. But I am not sure whats the time complexity. If input is something like "ababababababababababababababababababab..............." the this is n^2. Correct me if i am wrong?
Sir count in unordered_map will always be 1or 0?
Yes, mp.count(x) returns Number of elements with key x , that is either 1 or 0.
What is the use of storing count in the inside map? Cant we only store the vowel ct only
Why we are adding count to result instead of result++
Because every time ciunt is 1 only
❤❤❤❤❤❤❤
College se aake dekhta hu❤❤❤
🔥🔥
class Solution {
public:
long long beautifulSubstrings(string s, int k) {
int n = s.length();
unordered_mapmp;
mp[0].push_back(-1);
long long pre = 0;
long long ans = 0;
for(int i=0;i
I couldn't get why we need result += k. It should work with jaur result++ right?
result += k
Ensures that we are considering all such substrings.
This is exactly same as how we calculate “Find subarray count having sum 0” , in that also we don’t do result++.
Just run this example with result++ and you will realise what cases we will miss.
Example : s = “abba” , k = 1
@@codestorywithMIK But, here we are mapping k with count of vowels, and the count of vowels will always increase as we move in the string so k should always be 1 ig
Can someone explain please? 🥲
@@ashish2438 @codestorywithMIK Yes you are also right that since vow count always increase so it will work fine in doing ++ans also,
but the case he want to tell about is like
if we got same count let say 2 2 2 2 in vector we have 4 enteries if we have take map, but if we take map for the above thing it would be mp[pref][2] = 4 jo just in (order of 1) we will get this and our iteration will get reduces just by doing +k , here 4 count is stored in k.
in the problem the thing is we will never get this case because vowel count is always on increasing
we can get same (vow- con) but for that vow is always increasing so ++ans also work fine
but since he explain the prior problem where we are counting subarray with sum 0 now assume what i explain above that case 2, 2, 2, 2 if we not do +k in this case, we get wrong answer becuase 2 enteires are 4 but doing ++ only 1 subarray is counted, with reference do this case + k is very imp and also this is the reason we use map of map
because same thing can be done my map of vector also since we dont want to iterate for 2 2 2 2 again so he used map of map but again this case will never come so using map of vector also works fine.
I hope you understand the case where +k is used.
Same doubt have u got it?@@ashish2438
BHAIYA IS LEVEL TAK UNDERSTANDING LAANE KE LIYE KYA KHAANA PEENA HOGA ? CAN U SHARE UR DIET PLAN?
Sir do we need to memorize dsa question daily. I mean i understand this solution but do we need to revise such question whose intuition we not get directly
Don’t revise each qn.
Instead, revise topics, concepts periodically
why don't you first update map and then update the result , i.e line 37 should be at 27
GOAT
kaafi mushkil question tha, I dont know how people come up with a solution during contests!!
Hi there,
Actually these Qns are related to many others Qns in past. Most of the people who are able to solve it during contests have solved many many many such qns and it helps them to relate and come-out with the approach to solve Qns like these.
So always remember, it will come with a lot of practice and solving lots of problems.
If we start solving lots of HARD and Medium problems, then you will start seeing that contest hard problems are variations of such (mostly) .
for example: this week Sunday contest Qn - 4 , it was an amazing followup of already solved qn in past in my channel.
This is just one example and it happens mostly to all other hard problems.
Got it bhaiya, will definitely look to solve more such problems@@codestorywithMIK
GOAT