Wednesday, June 25, 2014

TopCoder High School SRM 13 Level one - 250 pt - Wall Repair solution

TopCoder High School SRM 13 Level one - 250 pt - Wall Repair statement: http://community.topcoder.com/stat?c=problem_statement&pm=6502&rd=10065

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

TopCoder High School SRM 13 Level one - 250 pt - Wall Repair solution:

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

class WallRepair {
    public: int bricksRequired(vector <string> w) {
        int a[55]={0}, cnt=0;
        for(int i=0; i<w.size(); i++) {
            for(int j=0; j<w[i].length(); j++) {
                if(w[i][j]=='X' && a[j]==0) a[j]=1;
                else if(w[i][j]=='.' && a[j]==1) cnt++;
            }
        }
        return cnt;
    }
};

No comments:

Post a Comment