# Number of Laser Beams in a Bank (LeetCode 2125) Product of consecutive non-empty device rows. ## Approach ```python def numberOfBeams(bank): prev = ans = 0 for row in bank: cur = row.count('1') if cur: ans += prev * cur prev = cur return ans ``` ## Complexity - Time / space depend on the scan above; keep the solution linear when possible. ## Interview tip Narrate the invariant before coding. I drill these patterns with [AI interview assistant](https://www.linkjob.ai/) ahead of OA rounds. *Disclosure: I work on Linkjob AI, an interview copilot. The algorithm above stands on its own.*