Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: gs

Problemset: เรียงสตริง

Language: cpp

Time: 0.003 second

Submitted On: 2025-12-07 20:42:47

// Online C++ compiler to run C++ program online
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string sort(string a){
    int len = a.size();
    for(int i = 0; i < len-1;i++){
        for(int j = 0; j < len-1; j++){
            if(a[j] > a[j+1]){
                char tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
            }
        }
    }
    return a;
}


int main() {
    // Write C++ code here
    string inp;
    cin >> inp;
    //cout << sort(inp);
    string sorted = sort(inp);
    vector<char> dedup;
    dedup.push_back(sorted[0]);
    for(int i = 1; i < sorted.size(); i++){
        if(dedup.back() != sorted[i]){
            dedup.push_back(sorted[i]);
        }
    }
    for(int i = 0; i < dedup.size(); i++){
        cout << dedup[i] << " ";
    }
}