---
# System prepended metadata

title: 2125. Number of Laser Beams in a Bank
tags: [Leetcode, Medium, Math]

---

# 2125. Number of Laser Beams in a Bank
###### tags: `Leetcode` `Medium` `Math`
Link: https://leetcode.com/problems/number-of-laser-beams-in-a-bank/description/
## Code
```python=
class Solution:
    def numberOfBeams(self, bank: List[str]) -> int:
        prev = 0
        ans = 0
        for i in range(len(bank)):
            cur = bank[i].count('1')
            if cur!=0:
                ans += prev*cur
                prev = cur
        return ans
```