Easiest Approach O(nxn) time || O(1) space
\n\n# Code\n\nclass Solution {\npublic:\n\n    //Idea is foe each row we go for next row which has security element if we reach to the last means no security el
\n\n# Code\n```\nclass Solution {\npublic:\n\n    //Idea is foe each row we go for next row which has security element if we reach to the last means no security elemnet between two rows. if we found the row we\'ll calculate the beams by multiplying the no. of 1s in both row & move curr row to the that row\n    int containes(string row){\n        int cnt=0;\n        for(int i=0;i<row.length();i++){\n            if(row[i]==\'1\')cnt++;\n        }\n        return cnt;\n    }\n    int numberOfBeams(vector<string>& bank) {\n        int res=0;\n        for(int i=0;i<bank.size()-1;i++){\n            int n=containes(bank[i]);\n            int j=i+1;\n            if(n){\n                for(;j<bank.size();j++){\n                    int m=containes(bank[j]);\n                    if(m){\n                        res+=(m*n);\n                        i=j-1;\n                        break;\n                    }\n                    \n                }\n            }\n            if(j==bank.size())break;\n        }\n        return res;\n\n        \n    }\n};\n```
['C++']