Simple Solution || Counting || C++ Clean Code
Code :\n\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        \n        int n = bank.size();\n        vector<int> cntOnes;\n      
# Code :\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        \n        int n = bank.size();\n        vector<int> cntOnes;\n        \n\t\t// Count number of ones in current bank\n        for(auto& b : bank) {\n            int cnt = 0;\n            for(auto& i : b) {\n                if(i == \'1\') cnt++;\n            }\n            cntOnes.push_back(c);\n        }\n        \n        int res = 0;\n        \n        int i = 0;\n        while(i<n && cntOnes[i] == 0) i++;\n        \n        for(i=0; i<n; ) {\n\t\t\t// Get the next bank index\n\t\t\t// Where there is atleast one device \n\t\t\t// i.e cntOnes >= 1\n            int j = i+1;\n            while(j < n && cntOnes[j] == 0) j++;\n            \n            if(j<n)\n                res += (cntOnes[i] * cntOnes[j]);\n            i = j;\n        }\n        \n        return res;\n    }\n};\n```\n\n**Complexity :**\n\n* Time : `O(N * M)`, N is size of `bank` list, and M is size of each string\n* Space : `O(N)`\n\n***If you find this helpful, do give it like :)***
['Counting']