Easy O(n) time complexity Cpp solution


#1

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