Sliding window solution
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing an array to record the apprent times of every bit \ndon\'t know how to use bitmap
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing an array to record the apprent times of every bit \ndon\'t know how to use bitmap, so using own code\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n# Code\n```\nclass Solution {\n    public int[] smallestSubarrays(int[] nums) {\n        \n        int len = nums.length;\n        int r = 0;\n        int b = len - 1;\n        int e = len - 1;\n        int[] res = new int[len];\n\n        int[] count = new int[32];\n\n        // b - e\n        while (b >= 0) {\n\n            r = r | nums[b];\n\n            add(count, nums[b]);\n\n            while (e > b && contains(count, nums[e])) {\n                remove(count, nums[e]);\n                e--;\n            }\n\n            res[b] = e - b + 1;\n\n            b--;\n        }\n\n        return res;\n    }\n\n    boolean contains(int[] count, int a) {\n\n        for (int i = 0; i < 32; i++) {\n            if ((a & 1) == 1) {\n                if (count[i] <= 1) {\n                    return false;\n                }\n            }\n            a = a >> 1;\n        }\n        return true;\n    }\n\n    void remove(int[] count, int a) {\n        for (int i = 0; i < 32; i++) {\n            if ((a & 1) == 1) {\n                count[i]--;\n            }\n            a = a >> 1;\n        }\n    }\n\n    void add(int[] count, int a) {\n\n        for (int i = 0; i < 32; i++) {\n            if ((a & 1) == 1) {\n                count[i]++;\n            }\n            a = a >> 1;\n        }\n    }\n}\n```
['Java']