Maximum Number of Vowels in a Substring of Given Length | MICROSOFT | Leetcode - 1456 | Live Coding

preview_player
Показать описание
This is the 8th Video of our Sliding Window Playlist.
In this video we will try to solve a very good and classic sliding window problem "Maximum Number of Vowels in a Substring of Given Length" (Leetcode-1456).

Problem Name : Maximum Number of Vowels in a Substring of Given Length
Company Tags : MICROSOFT

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

U r really doing great job dude ..your explanation is really great..❤

MadMaxXenon
Автор

Bro Aaj ka toh easy tha toh subah hi solve kr diya.

manimanohar_
Автор

Follow the series❤
you can solve it on one go
i=0
cnt=0
maxi=0
for j in range(len(s)):
if s[j] in "aeiou":
cnt+=1
while(j-i+1>k):
# shrink
if s[i] in "aeiou":
cnt-=1
i+=1
if j-i+1==k:
maxi=max(maxi, cnt)
return maxi
Done ✅

jagadeeshp
Автор

Your explainations are mind blowing. I have solved this problem myself without any hint. Thank you for this.

tarunsingh
Автор

Eagerly waiting for your video, if still I solved the challenge, your approach to question fabulous 😇

shivanshchauhan
Автор

You have the ability to make any problem look like a cake walk

wearevacationuncoverers
Автор

Watching at 2:30 am.! never stop humble request

youvanik
Автор

bro made it without seeing window seems easy pizzy .... thanks paaji

CodeMode
Автор

sirr pls make conceptual videos on remaining topics of dsa pls

simnidhnidh
Автор

Can you please tell when to use sliding window?? As
Only thing Im able to catch is length of specific k and substring. Is that it?? Or when the intuition should come???
As I was able to solve when I got that we can apply sliding window, but not getting when to use or when to think of it....

Ramneet
Автор

Ye question mein List use karke kiya par TLE de diya
int findNumVowels(list<char> &v){
int ctr = 0;
for (auto it = v.begin() ; it != v.end() ; ++it){
if (*it == 'a' or *it == 'e' or *it == 'i' or *it == 'o' or *it == 'u'){
ctr++;
}
}
return ctr;
}

int maxVowels(string s, int k) {
int n = s.size();
int i = 0, j = 0;
list<char> v;
int ans = INT_MIN;

while (j < n){
v.push_back(s[j]);

//window size not yet achived
if ((j-i+1) < k){
j++;
}

//window size achived
else if ((j-i+1) == k){
int num = findNumVowels(v);
ans = max(ans, num);
v.pop_front();
i++;
j++;
}
}

return ans;
}

pritishpattnaik
Автор

hey i hope aap jaldi reply kar do kyuki mujhe submit karna ahi
i write this code but it showes, BUT I USES THE SAME APPORCH AS YOU DID BUT CODE DIFFRENTLY
PS : CONDITION FOR INNER LOOP IS TAKEN FROM CHATGPT BEFOR THAT I AM USING "J<I+K" it worked for few test case but not work when i tried to submit
class Solution {
public:
int maxVowels(string s, int k)
{
int ans = INT_MIN;
for(int i = 0 ; i< s.length(); i++)
{
int count = 0;
for(int j = i ; j< min(i+k, (int)s.length()) ; j++)
{
if(s[j]=='a'|| s[j]=='i'|| s[j]=='e'||s[j]=='o'|| s[j]=='u')
{
count++;
}
}
ans=max(ans, count);
}

return ans;
}
};

tanishqdawar
join shbcf.ru