TopCoder High School SRM 20 Level one - 250 pt - Surname editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm20
TopCoder High School SRM 20 Level one - 250 pt - Surname solution:
#include <iostream> #include <vector> using namespace std; class Surname { public: int bestSurname(vector <string> s) { int a[15]={0}, ma=0, idx=0; for(int i=0; i<s.size(); i++) { for(int j=0; j<s[i].length(); j++) { a[i]+=s[i][j]; } } for(int i=0; i<s.size(); i++) if(a[i]>ma) ma=a[i], idx=i; return idx; } };
No comments:
Post a Comment