Simple Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Counting \'1\'s in Each Row:\n- Iterate through each row of the bank v
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Counting \'1\'s in Each Row:\n- Iterate through each row of the bank vector.\n- For each row, iterate through its characters and count the occurrences of \'1\'.\n- If there are \'1\'s in the row, add the count to the vect vector.\n\n```\nfor(int i = 0; i < bank.size(); i++){\n    int cnt = 0;\n    for(int j = 0; j < bank[0].size(); j++){\n        if(bank[i][j] == \'1\'){\n            cnt++;\n        }\n    }\n    if(cnt != 0)\n        vect.push_back(cnt);\n}\n\n```\n2. Handling Empty Bank:\n- Check if the vect vector is empty. If it is, return 0 since there are no \'1\'s in any row.\n```\nif(vect.size() == 0)\n    return 0;\n```\n3.Printing the Counts (Optional):\n- The code includes a loop to print the counts of \'1\' in each row. This is optional and can be omitted if not needed for debugging or analysis.\n```\nfor(int i = 0; i < vect.size(); i++){\n    cout << vect[i] << " ";\n}\n```\n4.Calculating Sum of Product of Consecutive Row Counts:\n- Iterate through the vect vector and calculate the sum of the product of consecutive elements.\n```\nint sum = 0;\nfor(int i = 0; i < vect.size() - 1; i++){\n    sum += vect[i] * vect[i+1];\n}\nreturn sum;\n\n```\n\n\n# Complexity\n- Time complexity:\nThe code iterates through each row of the bank vector, and for each row, it iterates through its characters to count the occurrences of \'1\'. The nested loops contribute to a time complexity of O(M * N), where M is the number of rows and N is the number of characters in each row.\nThe loop for calculating the sum of the product of consecutive row counts also has a linear time complexity, O(K), where K is the size of the vect vector.\nTherefore, the overall time complexity is O(M * N + K).=O(n2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\nThe overall space complexity is O(M) of vect vector.\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        // Declare a vector to store the count of \'1\' in each row\n        vector<int> vect;\n\n        // Iterate through each row in the bank\n        for(int i = 0; i < bank.size(); i++){\n            int cnt = 0;\n            \n            // Count the number of \'1\' in the current row\n            for(int j = 0; j < bank[0].size(); j++){\n                if(bank[i][j] == \'1\'){\n                    cnt++;\n                }\n            }\n\n            // If there are \'1\' in the row, add the count to the vector\n            if(cnt != 0)\n                vect.push_back(cnt);\n        }\n\n        // If no \'1\' is found in any row, return 0\n        if(vect.size() == 0)\n            return 0;\n\n        // Print the counts of \'1\' in each row\n        for(int i = 0; i < vect.size(); i++){\n            cout << vect[i] << " ";\n        }\n\n        // Calculate and return the sum of the product of consecutive row counts\n        int sum = 0;\n        for(int i = 0; i < vect.size() - 1; i++){\n            sum += vect[i] * vect[i+1];\n        }\n        return sum;\n    }\n};\n\n```
['C++']