Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created April 2, 2023 18:01
Show Gist options
  • Save qjatn0120/ba9f95507dd5b58e0dd233a63ed8a03b to your computer and use it in GitHub Desktop.
Save qjatn0120/ba9f95507dd5b58e0dd233a63ed8a03b to your computer and use it in GitHub Desktop.
#ifdef DEBUG
#include "debug.h"
#endif // DEBUG
#ifndef DEBUG
template <typename T>
void debug(T &x){}
#endif // DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr), ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
int n;
string s;
cin >> n >> s;
char minc = 'z';
int minp;
for(int i = 0; i < n; i++){
if(s[i] <= minc){
minc = s[i];
minp = i;
}
}
char tmp = s[minp];
s.erase(s.begin() + minp);
cout << tmp << s << "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment