Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll tc;
cin>>tc;
while(tc--)
{
ll n,k;
cin>>n>>k;
string s;
cin>>s;
string p;
p=s;
sort(p.begin(),p.end());
map<char,ll>mp;
for(int i=0;i<k;i++)
mp[p[i]]++;
string l;
for(int i=0;i<s.size();i++)
{
if(mp[s[i]]>0)
mp[s[i]]--;
else
l+=s[i];
}
if(l.size()==0) cout<<0<<endl;
else
cout<<l<<endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1006 Remove K Digits
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 18:37:41
- Judged At
- 2024-11-11 02:25:46
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 320.0 KiB