leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2125.cpp (322B)
0 class Solution {
1 public:
2 int numberOfBeams(const vector<string>& bank) const {
3 int res = 0, prev = 0;
4 for(const auto& floor: bank) {
5 int cnt = 0;
6 for(const char c: floor) cnt += c == '1';
7 if(cnt) res += cnt * prev, prev = cnt;
8 }
9 return res;
10 }
11 };