 Smallest Subarrays With Maximum Bitwise OR
Code


# Code
```java []
class Solution {
    public int[] smallestSubarrays(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        int []last=new int[30];

        for (int i = n-1; i >=0; i--) {

            ans[i]=1;

            for(int j=0;j<30;j++)
            {
                if((nums[i] & (1<<j))>0)
                {
                    last[j]=i;
                }

                ans[i]=Math.max(ans[i],last[j]-i+1);
            }
            



        }
        return ans;
    }
}

```
['Java']