Simple counting
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\nCount the number of 1s in the string. If its greater than 0 store it in
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\nCount the number of 1s in the string. If its greater than 0 store it in a variable x1.\n\nThen count the 1s in the next string.\n\nIf its greater than 0, add x1*count to result and make the value of x1 = count for the next cycle.\n\nNext value of count greater than 0 will be found and the process repeats.\n\n(Please upvote if you found it helpful).\n\n# Complexity\n\n- Time complexity:\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint count1(string s)\n{\n    int count = 0;\n\n    for(int i=0; i<s.length(); ++i)\n        if(s[i]==\'1\')\n            ++count;\n\n    return count;\n}\n\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n\n        int x1=0, count, res=0;;\n\n        for(int i=0; i<bank.size(); ++i)\n        {\n            count = count1(bank[i]); // psssing the string to count1 function.\n\n            if(count>0)\n            {\n                if(x1!=0)\n                {\n                    res+=x1*count; \n                    x1 = count;\n                }\n\n                else      // if x1 is not found, update x1 first.\n                    x1 = count; \n            }\n        }\n        \n        return res;\n    }\n};\n```
['C++']