A simple and easy approach
Intuition\n Describe your first thoughts on how to solve this problem. \nThe code is looping through each string in the input vector bank.\nWe need to count onl
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe code is looping through each string in the input vector bank.\nWe need to count only the number of 1\'s in every string.\n\n# Approach\n1. The code is looping through each string in the input vector bank.\n2. For each string, it counts the occurrences of \'1\'s.\n3. It accumulates the count of \'1\'s encountered so far by multiplying the current count of \'1\'s with the previous count and adding this to the answer.\n4. Finally, it returns the total count calculated.\n\n\n\n# Complexity\n- Time complexity:\n- O(N^2)\n\n- Space complexity:\n- O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        int ans=0;\n        int prevCnt =0;\n        int n =bank.size(),m=bank[0].size();\n        for(int i=0;i<n;i++){\n            int cnt=0;\n            for(auto s: bank[i]){\n                if(s==\'1\'){\n                    cnt++;\n                }\n            }\n            if(cnt>0){\n                // q.push(cnt);\n                ans += prevCnt*cnt;\n                prevCnt = cnt;\n            }else{\n                continue;\n            }\n        }\n       return ans;\n    }\n};\n```
['String', 'C++']