Skip to content

Commit 551ed6b

Browse files
authored
Update check-if-string-is-transformable-with-substring-sort-operations.cpp
1 parent 709a338 commit 551ed6b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

C++/check-if-string-is-transformable-with-substring-sort-operations.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
class Solution {
55
public:
66
bool isTransformable(string s, string t) {
7-
vector<vector<int>> idx(10);
7+
vector<vector<int>> idxs(10);
88
for (int i = size(s) - 1; i >= 0; --i) {
9-
idx[s[i] - '0'].emplace_back(i);
9+
idxs[s[i] - '0'].emplace_back(i);
1010
}
1111
for (const auto& c : t) {
1212
int d = c - '0';
13-
if (empty(idx[d])) {
13+
if (empty(idxs[d])) {
1414
return false;
1515
}
1616
for (int i = 0; i < d; ++i) { // a char can be moved left to the current position if it meets no smaller one
17-
if (!empty(idx[i]) && idx[i].back() < idx[d].back()) {
17+
if (!empty(idxs[i]) && idxs[i].back() < idxs[d].back()) {
1818
return false;
1919
}
2020
}
21-
idx[d].pop_back();
21+
idxs[d].pop_back();
2222
}
2323
return true;
2424
}

0 commit comments

Comments
 (0)