Problem consists of a string of length N and contains only small case alphabets.
It will be followed by Q queries, in which each query will contain an integer P (1<=P<=N) denoting a position within the string.
Mamta's task is to find the alphabet present at that location and determine the number of occurrence of same alphabet preceding the given location P.
Answers
Answered by
3
Answer:
aj mere friend ńę meko bye bola wo v chlti bus se I very happy
Answered by
0
Answer:int main()
{
int Q[100],i,j,count=0;
long int N,Qn;
char s[100],ch;
scanf("%ld",&N);
scanf("%s",s);
scanf("%ld",&Qn);
for(i=0;i<Qn;i++)
{
scanf("%d",&Q[i]);
}
for(i=0;i<Qn;i++)
{
ch=s[Q[i]-1];
count=0;
for(j=0;j<Q[i]-1;j++)
{
if(ch==s[j])
count++;
}
printf("%d",count);
}
return 0;}
Explanation:
Similar questions