Codeforces Round 823 (Div. 2) 1730C - Minimum Notation Solution
Problem Link : https://codeforces.com/problemset/problem/1730/C
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- string s ;
- cin >> s ;
- char mn = '9' ;
- for ( int i = s.size() - 1 ; i >= 0 ; i--) {
- mn = min (s[i] , mn) ;
- if (s[i] !='9' and mn < s[i])
- s[i]++ ;
- }
- sort(s.begin(),s.end()) ;
- cout << s <<"\n";
- }
- return 0 ;
- }
No comments