-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEasyTask.cpp
More file actions
41 lines (32 loc) · 898 Bytes
/
EasyTask.cpp
File metadata and controls
41 lines (32 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Solution{
public:
vector<char> easyTask(int n,string s,int q,vector<vector<string>> &queries){
vector<char> v;
for(int i=0;i<q;i++) {
if(queries[i][0]=="1") {
int index=stoi(queries[i][1]);
s[index]=queries[i][2][0];
}
else {
int start=stoi(queries[i][1]);
int end=stoi(queries[i][2]);
int k=stoi(queries[i][3]);
int freq[26]={0};
int count=0 ;
for(int j=start;j<=end;j++ ) {
freq[s[j]-'a']++;
}
for(int j=25;j>=0;j--) {
count+=freq[j];
if(count>=k)
{
count=j+'a';
break;
}
}
v.push_back(count);
}
}
return v;
}
};