Editorial -FREQ

Problem link Link
Author-Rishabh Verma
Editorialist - Rishabh Verma

Difficulty :
Easy

Problem
You are given a string and for that string some query are given . In each query you have to answer that how many time the character asked in the query is appeared in string before this .
Explanation
We input string and make an array of integer and initialise all its value as 0 .
now we make a map to check the character frequency. With the help of for loop we iterate in string to its length and with the help of map we check the frequency at that instant at store in array .
now we input query and output the value stored in array at for that value of query .
MY Solution

#include<bits/stdc++.h>
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    fast();
    string s;
      cin>>s;
      int n=s.length();
      int arr[n];
      std::map<char,int> mp;
      
      for(int i=0;i<n;i++){
          arr[i]=mp[s[i]]++;
      }
      int q,x;
      cin>>q;
      for(int i=0;i<q;i++){
          cin>>x;
          cout<<arr[x-1]<<endl;
      }
    return 0;
}