Easy Video Solution(C++,JAVA,Python)🔥 || Bit Manipulation 🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nThink in terms of bitwise AND Operator\n\n# Detailed and easy Video Solution\n\nhttps:/
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThink in terms of bitwise AND Operator\n\n# ***Detailed and easy Video Solution***\n\nhttps://youtu.be/iN7jRGQtVAE\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nOur code aims to find the maximum number of contiguous subarrays in an array that have the same bitwise AND value. It first calculates the common bitwise AND value for the entire array and then iterates through the array to count the number of subarrays with the same AND value, returning this count as the result.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n\n```C++ []\nclass Solution {\npublic:\n    int maxSubarrays(vector<int>& v) {\n        int m=33554431;\n        int n=v.size();\n        for(int i=0;i<n;i++)\n            m=m&v[i];\n        int s=33554431;\n        int c=0;\n        if(m==0)\n        {\n            for(int i=0;i<n;i++)\n            {\n                s=s&v[i];\n                if(i==n-1 && s!=m)\n                    return c;\n                if(s==m)\n                {\n                    s=33554431;\n                    c++;\n                } \n            }\n            return c;\n        }\n        return 1;\n    }\n};\n```\n```python []\nclass Solution:\n    def maxSubarrays(self, v):\n        m = 33554431\n        n = len(v)\n        \n        for i in range(n):\n            m = m & v[i]\n        \n        s = 33554431\n        c = 0\n        \n        if m == 0:\n            for i in range(n):\n                s = s & v[i]\n                if i == n - 1 and s != m:\n                    return c\n                if s == m:\n                    s = 33554431\n                    c += 1\n            return c\n        \n        return 1\n\n```\n```java []\nclass Solution {\n    public int maxSubarrays(int[] v) {\n        int m = 33554431;\n        int n = v.length;\n        \n        for (int i = 0; i < n; i++) {\n            m = m & v[i];\n        }\n        \n        int s = 33554431;\n        int c = 0;\n        \n        if (m == 0) {\n            for (int i = 0; i < n; i++) {\n                s = s & v[i];\n                if (i == n - 1 && s != m)\n                    return c;\n                if (s == m) {\n                    s = 33554431;\n                    c++;\n                } \n            }\n            return c;\n        }\n        \n        return 1;\n    }\n}\n```\n# ***If you like the solution Please Upvote and subscribe to my youtube channel***\n***It Motivates me to record more videos***\n\n***Thank you*** \uD83D\uDE00\n
['Bit Manipulation', 'C++', 'Java', 'Python3']