[C++][5-Lines][31ms][100%]
Complexity\n- Time complexity: O(nm)\n- Space complexity: O(1)\n\n# With Branch 35ms/99.9%\n\nclass Solution final {\n public:\n  static auto numberOfBeams(cons
# Complexity\n- Time complexity: $$O(nm)$$\n- Space complexity: $$O(1)$$\n\n# With Branch 35ms/99.9%\n```\nclass Solution final {\n public:\n  static auto numberOfBeams(const std::vector<std::string>& bank) -> int {\n    int ans{};\n    for (int prev{}; const auto& row : bank)\n      if (const int curr = std::ranges::count(row, \'1\'))\n        ans += std::exchange(prev, curr) * curr;\n    return ans;\n  }\n};\n```\n\n# Branchless 31ms/100%\n```\nclass Solution final {\n public:\n  static auto numberOfBeams(const std::vector<std::string>& bank) -> int {\n    int ans{};\n    for (int prev{}, curr; const auto& row : bank) {\n      for (curr = 0; const auto cell : row) curr += cell == \'1\';\n      ans += std::exchange(prev, (not curr) * prev + curr) * curr;\n    }\n    return ans;\n  }\n};\n```\n###### Original submissions with disabled io sync: \nhttps://leetcode.com/problems/number-of-laser-beams-in-a-bank/submissions/1135472932/\nhttps://leetcode.com/problems/number-of-laser-beams-in-a-bank/submissions/1135506537/
['C++']