Answer: ROCKWELL AUTOMATION | Off-Campus OA (2024) | Number of Laser Beams in a Bank

Answer · Posted Jun 2026

Approach Traverse every row. Count the number of devices (1s). Ignore empty rows. Whenever a non-empty row is found: Multiply its device count with the previous non-empty row's device count. Add the result to the answer. Update the previous device count. Strategy Initialize: prevDevices = 0 totalBeams = 0 Traverse each row. Count devices in the current row. If current row has devices: Add prevDevices × currentDevices to the answer. Update prevDevices. Return total beams. Java Code class Solution { ...

The full answer & interview discussion are available to premium members.

Log in Create a free account