Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
unsigned int t1,k;
cin>>t1>>k;
string s,s1,s2;
cin>>s;
///orginal string s1
s1=s;
vector<int> v;
///after swaping s
if(s.size()==k){
cout<<0<<endl;
}
else{
sort(s.rbegin(), s.rend());
int sz=s.size()-k;
for(int i=0; i<s1.size(); i++){
for(int j=0; j<sz; j++){
if(s1[i]==s[j]){
int d= s1[i]-'0';
v.push_back(d);
if(s1[i]=s[j]){
break;
}
}
}
}
for(int i=0; i<sz; i++){
cout<<v[i];
}
cout<<endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1006 Remove K Digits
- Contest
- Sylhet ICPC 2024 Collaborative Challenge: Episode 2
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-30 11:30:05
- Judged At
- 2024-10-30 11:30:05
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB