Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve(string s)
- {
- vector<int>num;
- for(auto i : s)
- num.push_back(i - '0');
- sort(num.begin(), num.end(), greater<>());
- string front = "", back = "";
- for(int i = 0; i < num.size(); i++)
- if (i%2 == 0)
- front += (char)('0'+num[i]);
- else
- back += (char)('0'+num[i]);
- reverse(back.begin(), back.end());
- front += back;
- cout << front;
- }
Advertisement
Add Comment
Please, Sign In to add comment