class Solution { public: bool isvowel(char ch) { return ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'; } bool halvesAreAlike(string s) { int i=0; int j=s.size()-1; int first=0; int second=0; while(i
2nd checks is while() is redundant : j = i+mid; public boolean halvesAreAlike(String s) { Set vowels = Stream.of('a','e','i','o','u','A','E','I','O','U') .collect(Collectors.toCollection(HashSet::new)); int N = s.length(), vLeft = 0, vRight = 0; for(int i=0; i
Hi there, These are not the Qns which are asked in Face to face round. Most of the times these Qns are asked in phone interviews for screening only. Once you clear screening round, you then go to further rounds where they ask Medium-Hard problems. I remember I was once asked in a Phone interview that which DS i will use for BFS . (Please note that i have noticed the level of qns have increased in many companies)
@@codestorywithMIK Hey I am following you from last 3-4 months now doing evey question and more likely able to do medium easy just got difficulty in hard ones and did like 440 questions is it enough to crack the faang interviews ?? Not now I'll like start apply after 6-7 months. And doing continue my DSA , I'm a frontend developer will also complete my backend till the time??( For intern).
class Solution {
public boolean halvesAreAlike(String s){
int mid=s.length()/2;
String fi=s.substring(0,mid);
String se=s.substring(mid);
int cntF=cntVowel(fi);
int cntS =cntVowel(se);
return cntF==cntS;
}
private int cntVowel(String t){
int cnt=0;
for(char c:t.toCharArray())
if("AEIOUaeiou".indexOf(c)!=-1)
cnt++;
return cnt;
}
}
tc=0(n);
sc=0(n);
👏🙏
Please also post today's GFG POTD
class Solution {
public:
bool isvowel(char ch)
{
return ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U';
}
bool halvesAreAlike(string s) {
int i=0;
int j=s.size()-1;
int first=0;
int second=0;
while(i
What is the time ans space complexity of both approaches can anyone please tell?
Hi, which application u use for drawing?
Hi beeram, i use the Default Note App in ipad 11 pro
class Solution {
public:
int vowCnt(string strings){
int cnt=0;
for(auto str:strings){
if(str=='a' || str=='e' || str=='i' || str=='o' || str=='u' || str=='A' || str=='E' || str=='O' || str=='U' || str=='I') cnt++;
}
return cnt;
}
bool halvesAreAlike(string s) {
int n=s.length();
if(n%2!=0) return false;
int i=n/2;
string s1=s.substr(0,i), s2=s.substr(n-i,i);
if(vowCnt(s1)==vowCnt(s2)) return true;
return false;
}
};
Bhaiya isn't this good solution?
That’s perfectly fine solution.
@@codestorywithMIK thank you bhaiya 🥰
2nd checks is while() is redundant :
j = i+mid;
public boolean halvesAreAlike(String s) {
Set vowels = Stream.of('a','e','i','o','u','A','E','I','O','U')
.collect(Collectors.toCollection(HashSet::new));
int N = s.length(), vLeft = 0, vRight = 0;
for(int i=0; i
Awesome
Gfg potd please
Thanks mik
sir, itna easy question google meta microsoft jaisi company kyu puchti haii??,i don't get it
Hi there,
These are not the Qns which are asked in Face to face round. Most of the times these Qns are asked in phone interviews for screening only.
Once you clear screening round, you then go to further rounds where they ask Medium-Hard problems.
I remember I was once asked in a Phone interview that which DS i will use for BFS .
(Please note that i have noticed the level of qns have increased in many companies)
@@codestorywithMIK Hey I am following you from last 3-4 months now doing evey question and more likely able to do medium easy just got difficulty in hard ones and did like 440 questions is it enough to crack the faang interviews ?? Not now I'll like start apply after 6-7 months. And doing continue my DSA , I'm a frontend developer will also complete my backend till the time??( For intern).
😃Done
Im able to solve easy to med problem (not like this one this was just a tp) but not med- hard. What do i do? 🥲🥲