fork download
  1.  
  2. void getAns(vector<string> & arr, vector<vector<int>> &queries){
  3. int n = arr.size();
  4. int prefixSum[26][totalSize]; //prefix[i][j] -> prefixSum of count of char i(a--z) till j(included)(0-n-1)
  5.  
  6. for(int i = 0; i < totalSize; i++){
  7. prefixSum[letter][i] = (i==0 ? 0 : prefixSum[letter][i-1]);
  8.  
  9. for(auto character: arr[i]){
  10. prefixSum[character - 'a'][i]++;
  11. }
  12. }
  13.  
  14. //Query = {l,r,k}
  15. for(auto query: queries){
  16. int l = query[0], r = query[1], k = query[2];
  17. int curTotalCount = 0;
  18.  
  19. for(int possibleAns = 0; possibleAns < 26; possibleAns++){
  20. curTotalCount += prefixSum[possibleAns][r] - (l==0 ? 0 : prefixSum[possibleAns][l-1]);
  21. if(curTotalCount >= k){
  22. cout << (possibleAns + 'a') << endl;
  23. break;
  24. }
  25. }
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:13: error: variable or field ‘getAns’ declared void
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
             ^~~~~~
prog.cpp:2:13: error: ‘vector’ was not declared in this scope
prog.cpp:2:20: error: ‘string’ was not declared in this scope
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                    ^~~~~~
prog.cpp:2:20: note: suggested alternative: ‘struct’
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                    ^~~~~~
                    struct
prog.cpp:2:30: error: ‘arr’ was not declared in this scope
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                              ^~~
prog.cpp:2:35: error: ‘vector’ was not declared in this scope
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                                   ^~~~~~
prog.cpp:2:42: error: ‘vector’ was not declared in this scope
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                                          ^~~~~~
prog.cpp:2:49: error: expected primary-expression before ‘int’
 void getAns(vector<string> & arr, vector<vector<int>> &queries){
                                                 ^~~
stdout
Standard output is empty