Thanks, bro, but I didn't understand why you started the second loop with 'i=k' (we only need to increment 'i' once). Let's say, for example, k=3; at that point, we don't check the values 0 and 1. Also, why should the condition be 'i
First loop populates our first window which is 'k' length. In second loop he is resuming loop from where we left off in first loop so we start at 'k'. I think we could have done this all in one loop tho.
Initially I used string to store aeiou then use string contains method to check if vowels are there or not , so iam guessing this check takes longer time than looking in Hashset
your explanation is on next level 🔥🔥...
and your final thoughts is really helpful
thank u so much..
thank you sir : )
thanks for the tutorial teacher
Thanks Brother .. Subscribed!!
Thanks, bro, but I didn't understand why you started the second loop with 'i=k' (we only need to increment 'i' once). Let's say, for example, k=3; at that point, we don't check the values 0 and 1. Also, why should the condition be 'i
First loop populates our first window which is 'k' length. In second loop he is resuming loop from where we left off in first loop so we start at 'k'. I think we could have done this all in one loop tho.
I didn’t understand your question.
Please make a playlist, so i can solve all these type of question at first and then watch your video if i got stuck
May be Elements of the array are contiguous .but string is also a char array,so,i think elements in the string also contiguous
Initially I used string to store aeiou then use string contains method to check if vowels are there or not , so iam guessing this check takes longer time than looking in Hashset
Hashset is the fastest
cpp
class Solution {
public:
int maxVowels(string s, int k) {
unordered_set vowel = {'a', 'e', 'i', 'o', 'u'};
int Max_vowel = 0;
int Window_vowel = 0;
for (int i = 0; i < k; i++) {
if (vowel.count(s[i])) {
Window_vowel++;
}
}
Max_vowel = Window_vowel;
for (int i = k; i < s.size(); i++) {
if (vowel.count(s[i - k])) {
Window_vowel--;
}
if (vowel.count(s[i])) {
Window_vowel++;
}
Max_vowel = max(Max_vowel, Window_vowel);
}
return Max_vowel;
}
};
Your sound feels like chocolate 🍫
hahah....
You are doing soo great Please never stop 🤌🏻✨✨