explained with image & comments, java beats 99%
\n\nCode:\n\n\tpublic int numberOfBeams(String[] bank) {\n        int total = 0;\n        int prev = 0;\n        for(int i=0;i<bank.length;i++){\n            in
\n\n**Code:**\n\n\tpublic int numberOfBeams(String[] bank) {\n        int total = 0;\n        int prev = 0;\n        for(int i=0;i<bank.length;i++){\n            int curr = countNum(bank[i]);\n            if(curr!=0){\n                total+= prev*curr;\n                prev = curr;\n            }\n        }\n        return total;\n    }    \n    \n    //returns number of \'1s\' in the String\n    int countNum(String row){\n        int count = 0;\n        for(char c : row.toCharArray())\n            if(c==\'1\') count++;   \n        return count;\n    }\n\t\n**Logic Explained with Comments:**\n\n        int total = 0;  // used to count total laser beams\n        int prev = 0;  // number of devices in previous row (ignoring empty ones)\n        \n        for(int i=0;i<bank.length;i++){\n            int curr = countNum(bank[i]); // number of devices in current row\n            if(curr!=0){  // if the row is not empty\n                total+= prev*curr;  // no. of beams b/w previous and current row will be prev*curr\n                prev = curr;  // now the current row will act as previous for the next rows\n            }\n\t\t}\n\t\n**Image:**\n![image](https://assets.leetcode.com/users/images/38656f1d-a340-4be5-82ba-825ed4f7646f_1644673643.437999.png)\n
['Java']