The equal-length strings in bank describe rows of cells. A 1 marks a security device and a 0 marks an empty cell. Two devices form one laser beam exactly when they are on different rows and every row strictly between them contains no devices. Their columns do not matter, and beams do not block each other. Return the total number of beams.
Filled circles mark security devices; dashed lines connect devices with laser beams.
Example 1:
Input: bank = ["101","000","011"]
Output: 4Explanation: The first and last rows each have two devices, with an empty row between them. Every device in the first row connects to both in the last row, giving 2 times 2 = 4 beams.
Example 2:
Input: bank = ["111"]
Output: 0Explanation: All devices are in the same row, so no pair meets the different-row condition.
Example 3:
Input: bank = ["10","01","10"]
Output: 2Explanation: There is one beam from row 0 to row 1 and one from row 1 to row 2. Row 1 contains a device, so row 0 cannot connect directly to row 2.
Constraints:
1 <= bank.length <= 5001 <= bank[i].length <= 500- All rows have the same length.
- Each character is
0or1.