Python3 | Simple Explanation | Skip, Count 1's and Multiply
Explanation\n\nFor finding total number of laser beams:\n\n1) Finding the no. of laser beams between adjacent rows. \nNote: A row here is considered only if it 
**Explanation**\n\nFor finding total number of laser beams:\n\n1) Finding the no. of laser beams between adjacent rows. \n**Note:** A row here is considered only if it has atleast 1 security device (atleast 1 "1" in string). Otherwise skiped that row.\n\n\tTo find the number of laser beams between adjacent rows we can multiply the number of security devices (no. of ones) in the first row and of second row.\n\n\tRepeat step-1 for finding the sum of all the laser beams from each pair of adjacent rows.\n\n**Algorithm**\n\nFor each string (element) in bank list:\n\ncount number of ones in string.\nMultiply count by the non-zero count of previous string.\nAdd it to ans.\n\n```\nclass Solution:\n    def numberOfBeams(self, bank: List[str]) -> int:\n        \n        first = -1 \n        ans = 0\n        for i in bank:\n            \n            temp = i.count("1")\n            \n            if temp == 0:\n                pass\n            else:\n                if first == -1:\n                    first = temp  \n                else:\n                    ans += (first*temp)\n                    first = temp\n        \n        return ans\n\n```\n\nTime Complexity: O(m * n)\nwhere, m = len of bank, n = len of string\nSpace: O(1)\n\n**Do Upvote if you like** \uD83D\uDE0A\uD83D\uDC4D
['Array', 'Math', 'String', 'Matrix', 'Python']