Practice Number of Laser Beams in a Bank
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
In the binary-string array bank, 1 marks a security device and 0 an empty cell. A pair of devices creates one beam if they are in different rows and every row strictly between those rows has no devices. Count all such pairs independently and return the total number of beams.
Source: Number of Laser Beams in a Bank on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
bank = ["011001","000000","010100","001000"]
Output
8
# Example 2
Input
bank = ["000","111","000"]
Output
0
Constraints
m == bank.length
n == bank[i].length
1 <= m, n <= 500
bank[i][j] is either '0' or '1'.
Related LeetCode Problems
Practice more problems similar to Number of Laser Beams in a Bank.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.