Java | Simple Counting | Greedy | Clean code
Complexity\n- Time complexity: O(m*n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity: $$O(m*n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int numberOfBeams(String[] bank) {\n    var onesA = 0;\n    var cnt = 0;\n\n    for (var row : bank) {\n      var onesB = 0;\n\n      for (var c : row.toCharArray())\n        if (c == \'1\') onesB++;\n      \n      if (onesB == 0) continue;\n\n      cnt += onesA * onesB;\n      onesA = onesB;\n    }\n    return cnt;\n  }\n}\n```\nIf you like my solution, please upvote it!
['Array', 'Math', 'String', 'Greedy', 'Matrix', 'Java']