Just Count the Lasers!! || C++ Easy✅💻
Intuition\n Describe your first thoughts on how to solve this problem. \nThe main Idea is to count the lasers in each row.\n# Approach\n Describe your approach 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe main Idea is to count the lasers in each row.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we make an array `lasers` which contains the number of lasers in each row.<br> NOTE : If we encounter any row which dosen\'t contains any lasers we will not push it into `lasers`.<br>\nNow the number of `beams` should be cumulative sum of `lasers[i]*lasers[i+1]`.<br>\nFOR EG : if there are two rows, `Row 1` contain `3` lasers and `Row 2` contains `4` lasers then the number of beams should be :\n```\nNumber of Lasers in Row1 * Number of Lasers in Row2 = 3*4 = 12\n``` \n\n\n# Handling a Edge case\nIf `lasers.size()==0` simply return 0;\n\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        vector<int> lasers;\n        for(auto r : bank){\n            int ls = 0;\n            for(auto c : r){\n                if(c==\'1\') ls++;\n            }\n            if(ls) lasers.emplace_back(ls);\n            else continue;\n        }\n        if(lasers.size()==0) return 0;\n        int beams = 0;\n        for(int i = 0;i<lasers.size()-1;i++){\n            int prod = lasers[i]*lasers[i+1];\n            beams+=prod;\n        }\n        return beams;\n    }\n};\n```
['C++']