Count Vowel Strings in Ranges | Simple Thought Process | Leetcode 2559 | codestorywithMIK

  Рет қаралды 6,358

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер
@riteshhhhh_01
@riteshhhhh_01 5 күн бұрын
tomorrow's quote from my side: "Tell me how bad you want it"
@codestorywithMIK
@codestorywithMIK 5 күн бұрын
🔥🔥🔥 Will use it
@gui-codes
@gui-codes 5 күн бұрын
How bad do I want it? Bad enough to wake up early, stay up late, and push through every challenge. Bad enough to silence doubt, ignore excuses, and outwork everyone else. Want it so bad that giving up isn't an option-it's the fuel that drives me forward every single day.
@harjotanand834
@harjotanand834 4 күн бұрын
Done with segment Tree ....MIK sir's playlist 🛐🛐🛐🛐
@Shreya-x1f
@Shreya-x1f 5 күн бұрын
Good morning, sir. In 2024, I achieved, learned, and developed a lot, but discovering your channel felt like my manifestation had come true. I have been consistently watching your videos for the past 3-4 months, and your consistency has greatly motivated me, sir. Thank you so much for being my all-time guiding brother. Wishing you a very Happy and healthy New Year, sir✨!
@hellsterkun8764
@hellsterkun8764 5 күн бұрын
Great Story Sir!
@yashraj5898
@yashraj5898 4 күн бұрын
Thank you so much sir< i was hoping from one video to another but found your channel. Thank you so much bhayia. and best wishes for the new year.
@SachinYadav-yx1rc
@SachinYadav-yx1rc 4 күн бұрын
Thank you for explaining
@gui-codes
@gui-codes 5 күн бұрын
I was able to solve this on my own. 1st Jan - Done on my Own (Took your help from video in Approach-3) 2nd Jan - Done
@joydeep-halder
@joydeep-halder 5 күн бұрын
Thank you bhaiya. Aj ka question sach me bahut easy tha.
@bhuppidhamii
@bhuppidhamii 4 күн бұрын
I got this video in my home feed. KZbin knows I need to learn coding
@imPriyansh77
@imPriyansh77 5 күн бұрын
Marked my attendance, Bhaiya!! Happy New Year to you!!!
@subasm2160
@subasm2160 4 күн бұрын
First thing that came to my mind after reading the question is segment tree, wrote the code and it got accepted, here to see another approach. Love your videos and explanation ❤
@LeetCode-Satish
@LeetCode-Satish 4 күн бұрын
thank you😊 pura samjh aa gya
@algosafari
@algosafari 5 күн бұрын
sir you are great love you sir❣
@amankrsingh9609
@amankrsingh9609 4 күн бұрын
You make every question easy....I was able to solve the question after the explanation but 91 textcase pe fatgya then i got the accSum concept maja aa gya
@sarangkale6761
@sarangkale6761 5 күн бұрын
Marked My attendance sir 😅
@gauravmundhada1647
@gauravmundhada1647 5 күн бұрын
Very easy question.
@vishwashsoni610
@vishwashsoni610 4 күн бұрын
sir this is how i solved this question : class Solution { public: vector vowelStrings(vector& words, vector& queries) { int n = words.size(); vector vowels(n, 0); for (int i = 0; i < n; i++) { bool checkStart = (words[i][0] == 'a') || (words[i][0] == 'e') || (words[i][0] == 'i') || (words[i][0] == 'o') || (words[i][0] == 'u'); bool checkEnd = (words[i].back() == 'a') || (words[i].back() == 'e') || (words[i].back() == 'i') || (words[i].back() == 'o') || (words[i].back() == 'u'); vowels[i] = (checkStart && checkEnd) ? 1 : 0; if (i > 0) { vowels[i] += vowels[i - 1]; } } int m = queries.size(); vector result(m, 0); for (int i = 0; i < m; i++) { int l = queries[i][0]; int r = queries[i][1]; if (l == 0) { result[i] = vowels[r]; } else { result[i] = vowels[r] - vowels[l - 1]; } } return result; } };
@aizad786iqbal
@aizad786iqbal 5 күн бұрын
it's easy if you know the pattern and medium if u didn't , so it's correctly marked... also if brute force worked then we could have said it's easy, a good problem for beginners
@codestorywithMIK
@codestorywithMIK 5 күн бұрын
Absolutely! ❤️
@m_fi8926
@m_fi8926 4 күн бұрын
Thanks MIK.
@best4567
@best4567 5 күн бұрын
Using Set : class Solution { public: vector vowelStrings(vector& words, vector& queries) { int n = words.size(); vector result; unordered_set st = {'a' , 'e' , 'i' , 'o' , 'u'}; vector cumSum(n); int sum = 0; for(int i=0 ; i 0)result.push_back(cumSum[r] - cumSum[l-1]); else result.push_back(cumSum[r]); } return result; } };
@rajeshkumar-ws5ku
@rajeshkumar-ws5ku 4 күн бұрын
we can also solve using map in c++ class Solution { public: vector vowelStrings(vector& words, vector& queries) { /// here we write a code // traverse all words of an array words unordered_map mp; int count=0; int cnt=0; /// its time complexity is 0(n) for(auto it : words){ int n=it.size(); char first=it[0]; char last=it[n-1]; if( (first=='a' || first=='e' || first=='i' || first=='o' || first=='u') && (last=='a' || last=='e' || last=='i' || last=='o' || last=='u')){ cnt++; } mp[count]=cnt; count++; } /// now we apply operations on queries vector result; for(auto & q : queries){ int first=q[0]; int last=q[1]; int count1=0; count1=mp[last] - ( first==0 ? 0 : mp[first-1] ) ; result.push_back(count1); } return result; } }; /// time complexity 0( m + n); /// space complexity (m)
@MohammedHasmi577
@MohammedHasmi577 5 күн бұрын
Good morning sir ❤🎉
@anonymous_246
@anonymous_246 4 күн бұрын
0:56 applying recursion in real life.
@devilinside54
@devilinside54 5 күн бұрын
Sir please make video on pattern based problem please🙏🙏🙏
@abhinavgarg0077
@abhinavgarg0077 4 күн бұрын
thanks for sharing,
@shubhamsahay5806
@shubhamsahay5806 5 күн бұрын
class Solution { public: bool isVowel(string &s){ char st = s[0]; char e = s[s.size()-1]; return (st == 'a' || st == 'e' || st == 'i' || st == 'o' || st == 'u') && (e == 'a' || e == 'e' || e == 'i' || e == 'o' || e == 'u'); } vector vowelStrings(vector& words, vector& queries) { vector preSum(words.size()); vector ans; if(isVowel(words[0])) preSum[0] = 1; for(int i = 1;i < words.size(); i++){ if(isVowel(words[i])){ preSum[i] = preSum[i-1] + 1; } else{ preSum[i] = preSum[i-1]; } } for(auto vec : queries){ int l = vec[0]; int r = vec[1]; if(l > 0){ ans.push_back(preSum[r] - preSum[l-1]); } else{ ans.push_back(preSum[r]); } } return ans; } };❤❤
@jeevan-23
@jeevan-23 4 күн бұрын
Done with segment trees
@VaibhavSingh_code
@VaibhavSingh_code 5 күн бұрын
har question easy hai medium bhi hard bhi aur easy to easy hai he
@masterLight313
@masterLight313 5 күн бұрын
This question is actually easy and only need preprocessed data to simply get queries data, self solved as below: vector vowelStrings(vector& words, vector& queries) { int n = words.size(); vector chk(n); unordered_set vow {'a', 'e', 'i', 'o', 'u'}; vector res; for(int i=0; i
@aditya12881
@aditya12881 5 күн бұрын
Sir it's request make video on cpp sir ,you are great teacher need it .please sir
@Coder_Buzz07
@Coder_Buzz07 5 күн бұрын
Bhaiya pattern based problem ka ek video bana dona plsss❤❤
@amtm0511
@amtm0511 4 күн бұрын
how important is it to solve daily question? does it help and should i consistently give time to daily challenges?
@RishabhRaj-ox2dd
@RishabhRaj-ox2dd 5 күн бұрын
bhai aap jharkhand mei kahan se ho .... btw your method of teaching is exceptional ,..................
@gui-codes
@gui-codes 5 күн бұрын
LinkedIn me sir k profile me school me Vivekananda Central School mentioned hai. Which seems to be in Hazaribagh, Jharkhand. Poora stalk karliya hai maine MIK sir ko 😂
@aws_handles
@aws_handles 5 күн бұрын
Entering 2025 with solving Qns 😊 I wish everyone of you are able to crack your dream company jobs . ❤
@kanavbansal450
@kanavbansal450 5 күн бұрын
Bhaiya segment tree se bhi seekho do ye question please
@thefinancialdiet4458
@thefinancialdiet4458 4 күн бұрын
sir please give FAANG playlist to us
@abhisheksingh-rz8nj
@abhisheksingh-rz8nj 4 күн бұрын
class Solution { public: bool isVowel(string s, int n) { bool ans = false; if(n==1 && (s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u')){ ans = true; return ans; } if ((s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u') && (s[n-1] == 'a' || s[n - 1] == 'e' || s[n - 1] == 'i' || s[n - 1] == 'o' || s[n - 1] == 'u') && n>1) { ans = true; return ans; } return ans; } vector findPrefixSum(vector& words) { int n = words.size(); vector prefixArray(n, 0); for (int i = 0; i < n; i++) { string currentString = words[i]; int currentStringLength = words[i].length(); cout
@crazygamerrohan9899
@crazygamerrohan9899 5 күн бұрын
Solved By My Own . 🤎
@Muigoku49
@Muigoku49 5 күн бұрын
Bhai dp series continue kar do please!!!!!!!!!!!!!!
@gui-codes
@gui-codes 5 күн бұрын
yes please
@gauravmundhada1647
@gauravmundhada1647 5 күн бұрын
+1
@omstechorbit
@omstechorbit 5 күн бұрын
Hello
@100solarmass
@100solarmass 4 күн бұрын
Something new ;) class Solution { public int[] vowelStrings(String[] words, int[][] queries) { int[] ans = new int[queries.length]; int[] count = new int[words.length]; HashSet set = new HashSet(); for (int i = 0; i < words.length; i++) { String x = words[i]; if (x.matches("^[aeiou]$") || x.matches("^[aeiou].*[aeiou]$")) { if (i == 0) { count[i] = 1; set.add(x); } else { count[i] = count[i - 1] + 1; set.add(x); } } else { if (i == 0) { count[i] = 0; } else count[i] = count[i - 1]; } } for (int i = 0; i < queries.length; i++) { int start = queries[i][0]; int end = queries[i][1]; if(start==0){ ans[i]=count[end]; }else{ ans[i] = count[end]-count[start-1]; } } return ans; } }
@gauravparasar4571
@gauravparasar4571 4 күн бұрын
mera aaaj amazon ka OA hai yr dar lagra hai
@gui-codes
@gui-codes 4 күн бұрын
bhai ekdm calm mind se dena. Acha jaega. All the best. Do share your experience.
@gauravparasar4571
@gauravparasar4571 4 күн бұрын
@gui-codes thanks bhai
@codestorywithMIK
@codestorywithMIK 4 күн бұрын
Dear Gaurav, You got this. Stay confident and give your best always ❤️ Don’t worry about the result, just give your 100%
@hare_krishna8411
@hare_krishna8411 5 күн бұрын
bhaiya raadhe raadhe
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
The Lost World: Living Room Edition
0:46
Daniel LaBelle
Рет қаралды 27 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 190 М.
Prefix Sum in 4 minutes | LeetCode Pattern
4:13
AlgoMasterIO
Рет қаралды 13 М.
The Ultimate Tier Programming Tier List | Prime Reacts
26:57
ThePrimeTime
Рет қаралды 518 М.
Pick these tech to make or destroy your tech career
15:52
Chai aur Code
Рет қаралды 108 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 335 М.
Arpit Bhayani talks about real engineering for 1 hour straight
1:16:23