Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth All Vowels problem solution

YASH PAL, 31 July 202414 February 2026
In this HackerEarth All Vowels problem solution Vowels are very essential characters to form any meaningful word in the English dictionary. There are 5 vowels in the English language – a, e, i, o u. You are given a random string containing only lowercase letters and you need to find if the string contains ALL the vowels.
 
 
HackerEarth All Vowels problem solution

 

 

HackerEarth All Vowels problem solution.

#include <bits/stdc++.h>

#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define elif else if
#define pii pair< int, int>
#define mp make_pair
#define pb push_back
using namespace std;
#define gc getchar_unlocked

int randi(int l,int r)
{
if(r<l)
return l;
return rand()%(r-l+1) +l;
}

int done[5]={0};
int main()
{
freopen("in.txt","r",stdin);
freopen("out","w",stdout);
int i,j,n,mi=99999,ma=0;
cin>>n;
string st;
cin>>st;
rep(i,n)
{
if(st[i]=='a')
done[0]++;
if(st[i]=='e')
done[1]++;
if(st[i]=='i')
done[2]++;
if(st[i]=='o')
done[3]++;
if(st[i]=='u')
done[4]++;
}
rep(i,5)
{
if(!done[i])
{
cout<<"NO";
return 0;
}
}
cout<<"YES";
return 0;
}
 

Second solution

#include<bits/stdc++.h>
using namespace std;
int main(){

int N;
string S;
cin>>N>>S;
assert(N>=1 && N<=10000);
assert(S.length()==N);
// a,e,i,o,u
bool flag1=false,flag2=false,flag3=false,flag4=false,flag5=false;
for(int i=0;i<N;i++){
if(S[i]=='a')
flag1=true;
else if(S[i]=='e')
flag2=true;
else if(S[i]=='i')
flag3=true;
else if(S[i]=='o')
flag4=true;
else if(S[i]=='u')
flag5=true;

if(flag1==true && flag2==true &&flag3==true && flag4==true && flag5==true)
break;
}

if(flag1==true && flag2==true &&flag3==true && flag4==true && flag5==true)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;

}
 
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes