Skip to content

Instantly share code, notes, and snippets.

@tabekg
Last active October 28, 2018 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tabekg/396ef7f906b5526283ff0320a8c61735 to your computer and use it in GitHub Desktop.
Save tabekg/396ef7f906b5526283ff0320a8c61735 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int b;
string a, d;
cin >> a;
cin >> b;
d = a;
sort(d.begin(), d.end());
int c = 0;
bool e[b];
for (int i = 0; i < a.size(); i++){
bool found = false;
if (c < b){
for (int j = 0; j < b; j++){
if (!found) found = d[j] == a[i];
if (found) e[i] = true;
}
}
if (found) c++;
else if (!e[i]) cout << a[i];
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment