class Solution {
public:
bool isTransformable(string s, string t) {
vector<deque<int>> pos(10);
for(int i=0;i<s.size();i++){
pos[s[i]-‘0‘].push_back(i);
}
for(char c:t){
if(pos[c-‘0‘].empty()) return false;
for(int i=0;i<c-‘0‘;i++){
if(!pos[i].empty() && pos[i].front()<pos[c-‘0‘].front()) return false;
}
pos[c-‘0‘].pop_front();
}
return true;
}
};
LC 1585. Check If String Is Transformable With Substring Sort Operations
原文:https://www.cnblogs.com/FEIIEF/p/13670963.html