Created
April 2, 2023 18:01
-
-
Save qjatn0120/ba9f95507dd5b58e0dd233a63ed8a03b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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