✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1 - The Most Concise\nTime complexity: O
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1 - The Most Concise\nTime complexity: $$O(m*n)$$. Space complexity: $$O(1)$$.\n```python3\nclass Solution:\n    def numberOfBeams(self, b: List[str]) -> int:\n        return sum(map(prod,pairwise(c for r in b if (c:=r.count(\'1\')))))\n```\n\n# Code #2 - Without Walrus\nTime complexity: $$O(m*n)$$. Space complexity: $$O(1)$$.\n```python3\nclass Solution:\n    def numberOfBeams(self, b: List[str]) -> int:\n        return sum(map(prod,pairwise(filter(int,(r.count(\'1\') for r in b)))))\n```\n\n# Code #3 - Extravagant Solution Using reduce\nTime complexity: $$O(m*n)$$. Space complexity: $$O(1)$$.\n```python3\nclass Solution:\n    def numberOfBeams(self, b: List[str]) -> int:\n        return reduce(lambda p,r:(c:=r.count(\'1\')) and (p[0]+p[1]*c,c) or p,b,(0,0))[0]\n```\n\n(Disclaimer 2: code above is just a product of fantasy packed into one line, it is not claimed to be \'true\' oneliners - please, remind about drawbacks only if you know how to make it better)
['Array', 'String', 'Matrix', 'Python', 'Python3']