Sunday, July 20, 2014

TopCoder High School SRM 40 Level one - 250 pt - Secretary solution and C++ vector reverse

TopCoder High School SRM 40 Level one - 250 pt - Secretary statement: http://community.topcoder.com/stat?c=problem_statement&pm=8055&rd=10784

TopCoder High School SRM 40 Level one - 250 pt - Secretary editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm40

TopCoder High School SRM 40 Level one - 250 pt - Secretary solution: 


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Secretary {
    public: string wrongOrdering(vector <string> f) {
        string s;
        for(int i=0; i<f.size(); i++) reverse(f[i].begin(), f[i].end()); 
        sort(f.begin(), f.end());
        reverse(f[0].begin(), f[0].end());
        s=f[0];
        return s;
    }
};

C++ vector reverse: http://www.cplusplus.com/reference/algorithm/reverse/


No comments:

Post a Comment