✔️ Simple C++ solution || Time complexity-O(m*n) || With Explaination
Approach\n\n Count the number of 1\'s in each row \n Store the count (if count>0) in a temporary array.\n Multiply every two adjacent elements of the array \n A
**Approach**\n\n* Count the number of 1\'s in each row \n* Store the count (if count>0) in a temporary array.\n* Multiply every two adjacent elements of the array \n* Add them all and return the value.\n\n**Solution**\n\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        vector<int> temp;\n        for(int i=0;i<bank.size();i++){\n            int cnt=count(bank[i].begin(),bank[i].end(),\'1\');     // Count the number of 1 \n            if(cnt>0)                                             // If there is no 1 in the row then that row can be skipped\n                temp.push_back(cnt);                              // i.e- Only store the rows which have number of 1\'s > 0\n        }\n        temp.push_back(0);                                        // If there is only 1 row in the input then to do multiplication adding aother row.   \n        int ans=0;\n        for(int i=0;i<temp.size()-1;i++){\n            ans+=temp[i]*temp[i+1];\n        }\n        return ans;\n    }\n};\n\n// PLEASE UPVOTE \n```
[]