Saturday, June 7, 2014

Topcoder High School SRM 7 Level one - 250 pt - Text Processor solution

Topcoder High School SRM 7 Level one - 250 pt - Text Processor statement: http://community.topcoder.com/stat?c=problem_statement&pm=6002&rd=10059

Topcoder High School SRM 7 Level one - 250 pt - Text Processor editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm7

Topcoder High School SRM 7 Level one - 250 pt - Text Processor solution: 

#include <iostream>
#include <cctype>
#include <algorithm>

using namespace std;

class TextProcessor {
    public: string collectLetters(string text) {
        string s="";
        for(int i=0; i<text.length(); i++) if(isalpha(text[i])) s+=tolower(text[i]);
        sort(s.begin(), s.end());
        return s;
    }
};

No comments:

Post a Comment