✅ My unique approach🚀Best Explanation and Easy to understand💪, Beat 96% in C++ and 93% in python
Intuition\n# PYTHON and PYTHON3 :\n1. Initialization : The variable \'ans\' is initialized to 0. This variable will be used to store the final result.\n2. Loop 
# Intuition\n# **PYTHON and PYTHON3 :**\n1. Initialization : The variable \'ans\' is initialized to 0. This variable will be used to store the final result.\n2. Loop to Remove Elements without \'1\' Characters : This loop iterates through the elements of the bank list in reverse order (from the last element to the first) so it avoid the \'index out of range\' error. For each element, it counts the occurrences of the character \'1\' and assigns it to the variable \'c\'. If \'c\' is equal to 0 (meaning there are no \'1\' characters in the string), the element is removed from the bank list. The purpose is to eliminate elements from bank that do not contain any \'1\' characters cause there is no need for that element which does not contain even a single \'1\' this element is a waste in the bank list although it does not effect the result answer but we should remove this so it cannot cause any calculation error.\n3. Check if There are Sufficient Elements in bank:\nif len(bank) > 1 : This condition checks whether there are more than one element in the modified bank list cause like we take the 2nd example of this problem bank = ["000","111","000"] here after removing the elements which does not contain \'1\' value in it and after removing them there is only one element left i.e. bank=[\'111\']\nso with only one element or single bank we can\'t do anything so in this case our answer is simply 0 if the bank condition does not follows this than it does not affect answer value which we have initialise int the start \'ans=0\' so it simply return the 0.\n4. Loop to Calculate Product of Counts for Pairs:\nif len(bank) > 1 : if this condition satisfy means banks contains more than one value:\nfor i in range(len(bank)-1):\n    c = bank[i].count(\'1\')\n    d = bank[i+1].count(\'1\')\n    ans = ans + (c * d)\nthan we can enter in loop, this loop iterates through the elements of the bank list from the first element to the second-to-last element. For each pair of consecutive elements, it calculates the count of \'1\' characters in each element (c and d), and adds the product of c and d to the \'ans\' variable. The purpose is to calculate the product of counts of \'1\' characters for pairs of consecutive elements in the modified bank list. basically it calculates the \'1\'s in consecutive elements and multiply them and add their multiplication to the \'ans\' variable. loop must iterate to len(bank)-1 so it can iterate properly on consecutive elements and not cause index errors.\n\n5. Return the Result : Finally, the method returns the calculated value of ans, which represents the sum of the products calculated in the previous step.\n\n\n---\n\n# **C++ :**\n**we have used the similar approach in C++:**\n1. The variable \'ans\' is initialized to 0. This variable will be used to store the final result.\n2. This loop iterates through the elements of the bank vector in reverse order (from the last element to the first). For each element, it counts the occurrences of the character \'1\' in that element using the count function from the <algorithm> header. If the count c is equal to 0, meaning there are no \'1\' characters in the string, the element is removed from the bank vector using erase.The purpose is to eliminate elements from bank that do not contain any \'1\' characters cause there is no need for that element which does not contain even a single \'1\' this element is a waste in the bank list although it does not effect the result answer but we should remove this so it cannot cause any calculation error.\nsummary: The purpose of this loop is to remove elements from the bank vector that do not contain any \'1\' characters.\n3. After the removal of elements without \'1\' characters, this conditional statement checks if the size of the modified bank vector is greater than 1. If true, it enters another loop that iterates through the elements of the bank vector from the first element to the second-to-last element. For each pair of consecutive elements, it calculates the count of \'1\' characters in each element (c and d), and adds the product of c and d to the ans variable.\nsummary: The purpose of this loop is to calculate the product of counts of \'1\' characters for pairs of consecutive elements in the bank vector.\n4. Finally, the method returns the calculated value of ans.\n\n\n\n **Thanks you all \uD83D\uDE4F for reading my solution i hope you understand this solution.**\n\n# Approach : Counting\n\n# Complexity\n- Time complexity: O(n^2)\n\n- Space complexity: O(n)\n\n# Code\n```C++ []\nclass Solution {\npublic:\n    int numberOfBeams(vector<string>& bank) {\n        int ans=0;\n        for(int i=bank.size()-1;i>=0;i--){\n            int c=count(bank[i].begin(),bank[i].end(),\'1\');\n            if(c==0){\n                bank.erase(bank.begin()+i);\n            }\n        }\n        if(bank.size()>1){\n            for(int i=0;i<bank.size()-1;i++){\n                int c=count(bank[i].begin(),bank[i].end(),\'1\');\n                int d=count(bank[i+1].begin(),bank[i+1].end(),\'1\');\n                ans=ans+(c*d);\n            }\n        }\n        return ans;\n        \n    }\n};\n```\n```Python3 []\nclass Solution:\n    def numberOfBeams(self, bank: List[str]) -> int:\n        ans=0\n        for i in range(len(bank)-1,-1,-1):\n            c=bank[i].count(\'1\')\n            if c==0:\n                bank.remove(bank[i])\n        if len(bank)>1:\n            for i in range(len(bank)-1):\n                c=bank[i].count(\'1\')\n                d=bank[i+1].count(\'1\')\n                ans=ans+(c*d)\n        return ans\n```\n```Python []\nclass Solution(object):\n    def numberOfBeams(self, bank):\n        """\n        :type bank: List[str]\n        :rtype: int\n        """\n        ans=0\n        for i in range(len(bank)-1,-1,-1):\n            c=bank[i].count(\'1\')\n            if c==0:\n                bank.remove(bank[i])\n        if len(bank)>1:\n            for i in range(len(bank)-1):\n                c=bank[i].count(\'1\')\n                d=bank[i+1].count(\'1\')\n                ans=ans+(c*d)\n        return ans\n```\n
['Counting', 'Python', 'C++', 'Python3']