🔥Clean Code | Easy | C++ |
Code\n\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        vector<int> rows;\n\n        for (int i = 0; i < bank.size(); i++)\n  
# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        vector<int> rows;\n\n        for (int i = 0; i < bank.size(); i++)\n        {\n            int one = 0;\n            for (int j = 0; j < bank[i].size(); j++)\n            {\n                if (bank[i][j] == \'1\')\n                {\n                    one++;\n                }\n            }\n            if (one != 0)\n            {\n                rows.push_back(one);\n            }\n        }\n        \n        int res = 0;\n        for (int i = 1; i < rows.size(); i++)\n        {\n            res += rows[i - 1] * rows[i]; \n        }\n        \n        return res;\n    }\n};\n```
['C++']