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

HackerEarth All Vowels problem solution

YASH PAL, 31 July 2024
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

Post navigation

Previous post
Next post

Related website

The Computer Science

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes