C++ Solution
Approach\nCount the security devices in the current and previous row, multiply them and add them to the ans.\n\n# Complexity\n- Time complexity:\nO(nm) \n\n- Sp
# Approach\nCount the security devices in the current and previous row, multiply them and add them to the ans.\n\n# Complexity\n- Time complexity:\n$$O(nm)$$ \n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        \n        int ans = 0;\n        int prev = 0 ;\n\n        for(string i : bank){\n            int t = 0; \n            for(int j = 0 ; j < i.size() ; j++){\n                if( i[j] == \'1\')\n                 t++;\n            }\n            if( t != 0 ){ \n            ans += prev*t ;\n            prev = t;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']