All Vowels

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 randoms string containing only lowercase letters and you need to find if the string contains ALL the vowels.

Example:

Input:  n = 8, s = "atuongih"
Output: NO

Approach

C++

#include <bits/stdc++.h>
using namespace std;

bool allVowels(int nstring s)
{

    int a[5] = {0};
    for (int i = 0i < ni++)
    {
        if (s[i] == 'a')
            a[0]++;
        else if (s[i] == 'e')
            a[1]++;
        else if (s[i] == 'i')
            a[2]++;
        else if (s[i] == 'o')
            a[3]++;
        else if (s[i] == 'u')
            a[4]++;
    }
    sort(aa + 5);
    if (a[0] > 0)
        return true;
    else
        return false;
}
int main()
{
    int n = 8;

    string s = "atuongih";

    if (allVowels(ns))
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


No comments:

Post a Comment