2411. Smallest Subarrays With Maximum Bitwise OR
Содержание
class Solution:
def smallestSubarrays(self, nums: List[int]) -> List[int]:
n = len(nums)
res = [1] * n
f = [-1] * 32
for i in range(n - 1, -1, -1):
t = 1
for j in range(32):
if (nums[i] >> j) & 1:
f[j] = i
elif f[j] != -1:
t = max(t, f[j] - i + 1)
res[i] = t
return res