Faster solution &&  without extra space  🚀
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N*M)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)  || N-Size of the input\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        int ans=0;\n        string str=bank[0];\n        int r1=0;\n        for(int i=0;i<str.length();i++){\n            if(str[i]==\'1\')\n                r1++;\n        }\n        for(int i=1;i<bank.size();i++){\n            string temp=bank[i];\n            int r2=0;\n            for(int i=0;i<temp.length();i++){\n                if(temp[i]==\'1\')\n                    r2++;\n            }\n            if(r2>0){\n                ans+=r1*r2;\n                r1=r2;\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']