Java Solution Time Complexity: O(N), Space Complexity: O(N)
Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\njava []\nclass Solution {\n\n    public int[] smallestSubarrays(int[] nums) {\n    
# Complexity\n- Time complexity:\n$$O(N)$$\n\n- Space complexity:\n$$O(N)$$\n\n# Code\n```java []\nclass Solution {\n\n    public int[] smallestSubarrays(int[] nums) {\n        int[] maximumBitWiseOR = new int[nums.length];\n        maximumBitWiseOR[nums.length - 1] = nums[nums.length - 1];\n        for (int index = nums.length - 2; index >= 0; index--)\n            maximumBitWiseOR[index] = nums[index] | maximumBitWiseOR[index + 1];\n        int[] smallestSubArrays = new int[nums.length];\n        int[] currentBitCounts = new int[32];\n        int start = 0;\n        for (int end = 0; end < nums.length; end++) {\n            append(currentBitCounts, nums[end]);\n            while (start <= end && value(currentBitCounts) == maximumBitWiseOR[start]) {\n                smallestSubArrays[start] = end - start + 1;\n                remove(currentBitCounts, nums[start++]);\n            }\n        }\n        return smallestSubArrays;\n    }\n\n    private int value(int[] currentBitCounts) {\n        int value = 0;\n        for (int index = 0; index < currentBitCounts.length; index++)\n            if (currentBitCounts[index] > 0) value |= (1 << index);\n        return value;\n    }\n\n    private void append(int[] currentBitCounts, int value) {\n        for (int index = 0; index < currentBitCounts.length; index++)\n            if ((value & (1 << index)) > 0) currentBitCounts[index]++;\n    }\n\n    private void remove(int[] currentBitCounts, int value) {\n        for (int index = 0; index < currentBitCounts.length; index++)\n            if ((value & (1 << index)) > 0) currentBitCounts[index]--;\n    }\n}\n```
['Bit Manipulation', 'Java']