Skip to content

Commit f46a2e4

Browse files
committed
Runtime: 966 ms (Top 29.96%) | Memory: 142.8 MB (Top 55.90%)
1 parent d13a2a2 commit f46a2e4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
// Runtime: 966 ms (Top 29.96%) | Memory: 142.8 MB (Top 55.90%)
12
class Solution {
23
public:
34
vector<bool> canMakePaliQueries(string s, vector<vector<int>>& queries) {
45
vector<vector<int>>table(s.size(), vector<int>(26,0));
56
vector<bool>ans;
6-
7+
78
table[0][s[0]-'a']++;
89
for(int i = 1; i != s.size(); i++){
910
for(int j = 0; j != 26; j++) table[i][j] = table[i-1][j];
1011
table[i][s[i]-'a']++;
1112
}
12-
13+
1314
for(auto &q: queries){
1415
int odd = 2 + (q[2]<<1);
1516
for(int i = 0; i != 26; i++){
1617
int val = table[q[1]][i] - (q[0] ? table[q[0]-1][i] : 0);
17-
if( (val & 1) && --odd == 0){ans.push_back(false); goto mark;}
18+
if( (val & 1) && --odd == 0){ans.push_back(false); goto mark;}
1819
}
19-
20+
2021
ans.push_back(true);
2122
mark:;
2223
}
23-
24+
2425
return ans;
2526
}
26-
};
27+
};

0 commit comments

Comments
 (0)