TopCoder High School SRM 14 Level one - 250 pt - Xox editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm14
TopCoder High School SRM 14 Level one - 250 pt - Xox solution:
#include <iostream> using namespace std; class Xox { public: int count(string s) { int cnt=0, b[55]={0}; for(int i=2; i<s.length(); i++) { if(b[i-2]==1 && s[i-1]=='o' && s[i]=='x') cnt+=2, b[i]=1; else if(s[i-2]=='x' && s[i-1]=='o' && s[i]=='x') cnt+=3, b[i]=1; } return cnt; } };
No comments:
Post a Comment