||✅Simplest approach ||updating two variables (a and b)  ✅||
Intuition\nThe goal is to find the number of beams formed between pairs of devices in a bank based on certain conditions.\n\n# Approach\n1. Initialize variables
# Intuition\nThe goal is to find the number of beams formed between pairs of devices in a bank based on certain conditions.\n\n# Approach\n1. Initialize variables `a`, `b`, `ans`, and `count` to keep track of the number of beams and the count of devices.\n2. Iterate through each row of the bank:\n   - For each row, count the number of devices with \'1\' (represented by `count`).\n   - Update `a` and `b` based on the counts, and reset `count` to 0.\n   - If both `a` and `b` are non-zero, add `a * b` to the total number of beams (`ans`).\n3. Return the final count of beams (`ans`).\n\n# Example\n## Input\n`bank = ["011001","000000","010100","001000"]`\n\n## Output\n`8`\n\n# Execution\n1. Initialize `a = 0`, `b = 0`, `ans = 0`, and `count = 0`.\n2. Iterate through each row:\n   - Row 1: Count devices with \'1\', `count = 3`. Update `a = 3`, `b = 0`, and reset `count`.\n   - Row 2: Count devices with \'1\', `count = 0`. Update `a = 0`, `b = 3`, and reset `count`.\n   - Row 3: Count devices with \'1\', `count = 2`. Update `a = 2`, `b = 3`, and reset `count`.\n   - Row 4: Count devices with \'1\', `count = 1`. Update `a = 1`, `b = 2`, and reset `count`.\n   - Calculate beams: `ans += a * b = 8`.\n3. Return `ans = 8` as the number of beams.\n\n# Complexity\n- Time complexity: O(rows * columns)\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\n    public int numberOfBeams(String[] bank) {\n        int a = 0, b = 0, ans = 0, count = 0;\n        for (int i = 0; i < bank.length; i++) {\n            for (int j = 0; j < bank[i].length(); j++) {\n                if (bank[i].charAt(j) == \'1\')\n                    count++;\n            }\n\n            if (count != 0) {\n                b = a;\n                a = count;\n                count = 0;\n            }\n            if (a != 0 && b != 0) {\n                ans += a * b;\n                b = 0;\n            }\n        }\n        return ans;\n    }\n}\n```
['Java']