Cpp O(n) Easy solution


#1

int Solution::solve(string A) {
int count=0;
int n=A.length();
for(int i=0;i<n;i++)
{
if(A[i]==‘A’|| A[i]==‘a’||A[i]==‘E’||A[i]==‘e’||A[i]==‘I’||A[i]==‘i’||A[i]==‘O’||A[i]==‘o’||A[i]==‘U’||A[i]==‘u’)
{
count+=n-i;
}
}
int mod=10003;
return count% mod;
}


#2

Did you take account of cases where duplicate counting is possible? for example in “abcabc”? Your code seems wrong.