Codeforces Round 823 (Div. 2) 1730C - Minimum Notation Solution


 

Problem Link :  https://codeforces.com/problemset/problem/1730/C

Solution in C++:

  1. /// Author : AH_Tonmoy
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int32_t main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. string s ;
  11. cin >> s ;
  12. char mn = '9' ;
  13. for ( int i = s.size() - 1 ; i >= 0 ; i--) {
  14. mn = min (s[i] , mn) ;
  15. if (s[i] !='9' and mn < s[i])
  16. s[i]++ ;
  17. }
  18. sort(s.begin(),s.end()) ;
  19. cout << s <<"\n";
  20. }
  21. return 0 ;
  22. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.