Computer Science, asked by gowdetilikhith28, 11 months ago

Constraints
1 <= N <= 500000

S consisting of small case alphabets

1 <= Q <= 10000

1 <= P <= N

Input Format
First line contains an integer N, denoting the length of string.

Second line contains string S itself consists of small case alphabets only ('a' - 'z').

Third line contains an integer Q denoting number of queries that will be asked.

Next Q lines contains an integer P (1 <= P <= N) for which you need to find the number occurrence of character present at the Pth location preceeding P.

Answers

Answered by aparadhamanasa65
1

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:

Answered by Jasleen0599
0

Writing the syntax in C language:

C is a broadly useful, procedural P C programming language supporting organized programming, lexical variable degree, and recursion, with static a kind framework. By plan, C gives builds that map effectively to common machine directions.

A screenshot of the syntax is attached.

Attachments:
Similar questions