Bank Heist🚨🚨 | Concise and simple| TC O(m*n)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\nCounting Beams: Instead of tracking individual beams, we can count the number of \'
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n**Counting Beams**: Instead of tracking individual beams, we can count the number of \'1\'s in each row, representing active lasers.\n\n**No of laser combinations till ith row can be calculated by no of lasers in previous active row and current row , If the row has not any lasers just skip it**\n\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Iterate through each row:\n- Count the number of lasers (\'1\'s) in the current row.\n- If the current row has any lasers:\n    - Multiply the count of lasers in the current row with the count of active lasers in the previous row \n    - Update the count of active lasers in the previous row with the count from the current row , if rows hasn\'t not any laser dont do any updation.\n\n2. Return the accumulated count of beam intersections.\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 {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        int n = bank.size();\n        int prev = 0; int ans = 0;\n        for(int i = 0;i<n;i++){\n            int count = 0;\n            for(int j = 0;j<bank[i].size();j++)\n                if(bank[i][j]==\'1\') count++; //count active lasers\n            ans+=(prev*count); // update the ans \n            if(count!=0) prev = count; // dont update prev if there are no lasers in the row\n        }\n      return ans;\n    }\n};\n```\n**If you find this solution helpful, consider giving it an upvote! Your support is appreciated. Keep coding, stay healthy, and may your programming endeavors be both rewarding and enjoyable!**\n\n# Join our WhatsApp Channel\nCheck out the link in comments\n\n\uD83D\uDE80 Elevate your coding skills to new heights! \uD83C\uDF1F Join our exclusive WhatsApp community channel dedicated to daily LeetCode challenges, interview problem-solving, and cutting-edge contest solutions.\n\n\uD83D\uDD0D Explore the world of Algorithms and unravel the secrets of Data Structures with us. \uD83E\uDDE0\uD83D\uDCBB\n\n\uD83C\uDFAF What\'s in for you?\n\nDaily LeetCode problems to sharpen your coding prowess.\nInterview problem discussions to ace your tech interviews.\nContest solutions and optimized approaches for a deeper understanding.\nShare new approaches, optimized solutions, and DSA tricks.\nBuild a strong logic foundation at no cost!\n\uD83E\uDD1D Be part of our coding journey, where we learn and grow together. \uD83D\uDCA1\uD83D\uDCBB
['Counting', 'C++']