Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int t1,k;
cin>>t1>>k;
string s,s1,s2;
cin>>s;
///orginal string s1
s1=s;
vector<char> 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]){
v.push_back(s1[i]);
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 10:55:52
- Judged At
- 2024-10-30 10:55:52
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 376.0 KiB