JAVA
Code\n\nclass Solution {\n    public int[] smallestSubarrays(int[] nums) {\n        int[] map = new int[32];\n        int[] ans = new int[nums.length];\n       
# Code\n```\nclass Solution {\n    public int[] smallestSubarrays(int[] nums) {\n        int[] map = new int[32];\n        int[] ans = new int[nums.length];\n        for (int i = nums.length - 1; i >= 0; i--) {\n            int num = nums[i];\n            for (int j = 0; j <= 31; j++) {\n                int mask = 1 << (j);\n                if ((num & mask) > 0) {\n                    map[j] = i;\n                }\n            }\n            int max = i;\n            for (int e : map)\n                max = Math.max(e, max);\n            ans[i] = max - i + 1;\n        }\n        return ans;\n    }\n}\n```
['Java']