UVA 12770 PalinaGram







#include <bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    vector<char>v;
    string s;
    int a[500];
    int i,j,k,c,n;
    //freopen("12770.txt","r",stdin);
    //freopen("12770out.txt","w",stdout);
    while(cin>>s)
    {
        memset(a,0,sizeof a);
        if(s=="#")
        {
            break;
        }

        for(i=0;i<s.length();i++)
        {
            a[s[i]]++;
            //cout<<a[s[i]]<<"="<<s[i]<<endl;

        }



        for(j=0;j<=128;j++)
        {
            if(a[j]%2!=0)
            {
                ch=j;
                //cout<<ch<<"="<<a[j]<<endl;
                v.push_back(ch);
            }
        }
        sort(v.begin(),v.end());
        for(k=0;k<v.size();k++)
        {
            if(k!=v.size()-1)
            {
                cout<<v[k];
            }

        }
        printf("\n");
        v.clear();
    }

    return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment