JAVA/C++ solution Explained in HINDI
https://youtu.be/K2J247xweb4\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F\n\nSubscribe link:- htt
https://youtu.be/K2J247xweb4\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F\n\nSubscribe link:- https://youtube.com/@quantumCode7?si=NzjWYmiCbqfFBUJE\n\nSubscribe Goal:- 100\nCurrent Subscriber:- 52\n\n# JAVA Code\n```\nclass Solution {\n    public int numberOfBeams(String[] bank) {\n        \n        int prevCount = 0;\n        int totalBeams = 0;\n\n        for (String s : bank) {\n            int currentCount = countOnes(s);\n\n            if (currentCount > 0) {\n                totalBeams += prevCount * currentCount;\n                prevCount = currentCount;\n            }\n        }\n\n        return totalBeams;\n    }\n\n    private int countOnes(String s) {\n        int count = 0;\n        for (char c : s.toCharArray()) {\n            if (c == \'1\') {\n                count++;\n            }\n        }\n        return count;\n    }\n}\n```\n# C++ Code\n```\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        int prevCount = 0;\n        int totalBeams = 0;\n\n        for (const string& s : bank) {\n            int currentCount = countOnes(s);\n\n            if (currentCount > 0) {\n                totalBeams += prevCount * currentCount;\n                prevCount = currentCount;\n            }\n        }\n\n        return totalBeams;\n    }\n\nprivate:\n    int countOnes(const string& s) {\n        int count = 0;\n        for (char c : s) {\n            if (c == \'1\') {\n                count++;\n            }\n        }\n        return count;\n    }\n};\n```
['Java']