Easy C++ solution in O(n) time complexity and O(1) space complexity


#1
int Solution::solve(string A) 
{
    unordered_set<char>dict;
    dict.insert('A');
    dict.insert('E');
    dict.insert('I');
    dict.insert('O');
    dict.insert('U');
    long long int count=0,n=A.length();
    for(int i=0;i<n;i++)
    {
        int x=int(A[i]);
        if(x>=97 && x<=122)
        {
            A[i]=A[i]-32;
        }
        if(dict.find(A[i])!=dict.end())
        {
            count=(count+(n-i))%10003;
        }
    }
    return count;
}