Simple Solution for beginners with dry run example cpp
Intuition:\nThe task is to count the number of independent laser beams between security devices placed in different rows within the bank\'s floor plan.\n\n# App
# Intuition:\nThe task is to count the number of independent laser beams between security devices placed in different rows within the bank\'s floor plan.\n\n# Approach:\nIterate through each row in the bank\'s floor plan.\nCount the number of security devices (\'1\'s) in each row.\nStore the counts of security devices in a vector named lasers.\nCalculate the number of beams by considering pairs of counts that satisfy the condition.\n# Complexity:\nTime complexity: O(M * N), where M is the number of rows and N is the number of columns in the bank\'s floor plan.\nSpace complexity: O(M), where M is the number of rows in the bank\'s floor plan.\nLet\'s illustrate this algorithm with a dry run using an example bank layout:\n<!-- Bank Layout -->\n# Example:\n### Bank layout\n<table border="1">\n  <tr>\n    <td>1</td>\n    <td>0</td>\n    <td>1</td>\n    <td>0</td>\n    <td>0</td>\n  </tr>\n  <tr>\n    <td>1</td>\n    <td>1</td>\n    <td>1</td>\n    <td>0</td>\n    <td>0</td>\n  </tr>\n  <tr>\n    <td>1</td>\n    <td>0</td>\n    <td>0</td>\n    <td>0</td>\n    <td>0</td>\n  </tr>\n  <tr>\n    <td>0</td>\n    <td>0</td>\n    <td>0</td>\n    <td>0</td>\n    <td>0</td>\n  </tr>\n</table>\n\n<!-- Explanation -->\n<h3>Explanation:</h3>\n<p>Count of security devices per row:</p>\n<table border="1">\n  <tr>\n    <td>Row 1</td>\n    <td>Row 2</td>\n    <td>Row 3</td>\n    <td>Row 4</td>\n  </tr>\n  <tr>\n    <td>2</td>\n    <td>3</td>\n    <td>1</td>\n    <td>0</td>\n  </tr>\n</table>\n\n<p>Pairs that satisfy the conditions:</p>\n<ul>\n  <li>(2, 3)</li>\n  <li>(3, 1)</li>\n</ul>\n\n<p>Number of beams = (2 * 3) + (3 * 1) = 6 + 3 = 9</p>\n\n# Code\n```\nstatic auto __ = []()\n{\n    std::ios_base::sync_with_stdio(false);\n    std::cin.tie(nullptr);\n    std::cout.tie(nullptr);\n    return 0;\n}();\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        vector<int> lasers;\n        for(string s:bank){\n            int ones = 0;\n            for(char c:s){\n                if(c == \'1\') ones++; \n            }\n            if(ones!=0) lasers.push_back(ones);\n        }\n        if(lasers.size() < 2) return 0;\n        int ans = 0;\n        for(int l = 0; l<lasers.size()-1 ; l++){\n            ans += lasers[l]*lasers[l+1];\n        }\n        return ans;\n    }\n};\n```\n# Same old shameless begging for upvote
['C++']