Simple C++ Solution 💡 ( Beats 100% ✅ )  Space complexity : O(1)  && Time complexity: O(n * m)
Intuition\nA laser beam is formed between devices (\'1\') in different rows. The idea is to check how many devices are in one row and multiply it with the numbe
# Intuition\nA laser beam is formed between devices (\'1\') in different rows. The idea is to check how many devices are in one row and multiply it with the number of devices in the next row that also has devices.\n\n# Approach\nStart with ans = 0 (to store the total beams) and prev = 0 (to keep track of the number of devices in the previous row).\nGo through each row of the bank:\n\nCount how many \'1\'s are in the current row (num).\nIf there are devices in the row (num > 0):\nMultiply prev (devices from the previous row) with num and add it to ans.\n        Update prev to num for the next row.\n\nAt the end, return ans, which is the total number of beams.\n\n# Complexity\n- Time complexity:\nO(m\xD7n)\n\n- Space complexity:\nO(1)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n\n        int ans = 0;\n        int prev = 0;\n\n        for (int i = 0; i < bank.size(); i++) {\n\n            int num = 0;\n\n            for (auto i : bank[i]) {\n                if (i == \'1\') {\n                    num++;\n                }\n            }\n\n            if (num > 0) {\n                ans += prev * num;\n                prev = num;\n            }\n            \n        }\n        \n        return ans;\n    }\n};\n```
['C++']