Code
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
vector<char>str(n);
vector<char>str2(n);
for(int i=0; i<n; i++){
char c;
cin>>c;
str[i]=c;
str2[i]=c;
}
sort(str.rbegin(), str.rend());
if (n == k)
{
cout << 0 << endl;
}
else
{
string st;
while (k--)
{
str.pop_back();
}
for(int i=0; i<str2.size(); i++){
int cnt=count(str.begin(), str.end(), str2[i]);
if(cnt==1){
st.push_back(str2[i]);
}
}
cout<<st<<endl;
}
}
}
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:25:58
- Judged At
- 2024-11-11 02:34:55
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB