Solution
General Idea: To print the letters of a string in alphabetical order, we can simply sort the string. In C++, the standard library function sort works on strings and sorts characters in ascending order (based on ASCII codes).
Time complexity: where is the length of the string.
#include <bits/stdc++.h>
using namespace std;
#define str string
#define all(x) x.begin(), x.end()
#define Moageza ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve() {
str s;
cin >> s;
sort(all(s));
cout << s << "\n";
}
signed main() {
Moageza
int t = 1;
while(t--) solve();
return 0;
}