#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    unordered_map<char,int>ump;
    for(int i=0;i<n;i++){
        if(ump.find(s[i])==ump.end())
        {
            ump[s[i]]=i;
        }else{
            ump[s[i]]=INT_MAX;
        }
    }
    
    for(auto it : ump){
        cout<<it->first<<" "<<it->second<<",";
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: