Best Solution || Python || Greedy || Beats 90%
Intuition\nLooking at the problem it conveys that multiplying the number of first row with non zero beams to the next row with non zero beams and then add the m
# Intuition\nLooking at the problem it conveys that multiplying the number of first row with non zero beams to the next row with non zero beams and then add the multiplication of second non zero beam row with third non zero beam row. \n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nGreedy\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(M*N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def numberOfBeams(self, bank: List[str]) -> int:\n        res_beams = 0\n        previous_beams = self.getbeams(bank[0])\n\n        for beams in range(1, len(bank)):\n            beamsInString = self.getbeams(bank[beams])\n            if beamsInString == 0:\n                continue\n            else:\n                tot_beams = beamsInString * previous_beams\n                res_beams +=  tot_beams\n                previous_beams = beamsInString\n\n        return res_beams\n\n    def getbeams(self, stringBeam):\n        beams = 0\n        for beam in stringBeam:\n            if beam == \'1\':\n                beams += 1\n        \n        return beams\n\n\n\n\n```
['Python3']