Smallest Subarrays With Maximum Bitwise OR
You're given a 0-indexed array, nums, of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you need to determine the size of the minimum-sized non-empty subarray of nums starting at i (inclusive) that has the maximum possible bitwise OR.
In other words, let Bij be the bitwise OR of the subarray nums[i...j]. You're required to find the smallest subarray starting at i such that the bitwise OR of this subarray is equal to max(Bik) where i ≤ k ≤ n - 1. The bitwise OR of an array is the bitwise OR of all the numbers in it.
Your function should print an integer array, answer, of size n where answer[i] represents the length of the minimum-sized subarray starting at i with maximum bitwise OR.
A subarray is defined as a contiguous non-empty sequence of elements within an array.
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?