Simplest in C++


#1

Comment body goes here.string Solution::solve(string A, int k) {
string s="";
for(auto x: A)
{
while(!s.empty() && s.back()>x && k) s.pop_back(),k–;
if(x!=‘0’ || !s.empty()) s.push_back(x);
}
while(!s.empty() && k) s.pop_back(),k–;
return (s.empty())?“0”:s;
}