Tap here to switch tabs
Problem
Submissions

Problem: Smallest Subarrays With Maximum Bitwise OR

med
30 min
Try to solve the Smallest Subarrays With Maximum Bitwise OR problem.

Statement

Given an integer array nums of length n.

For each index i from 00 to n −1- 1, consider all possible subarrays starting at index i. Among all these subarrays, determine the minimum length of a subarray whose bitwise OR is equal to the maximum bitwise OR achievable by any subarray starting at i.

Return an integer array answer of length n, where answer[i] is the minimum length of such a subarray starting at index i.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Subarrays With Maximum Bitwise OR

med
30 min
Try to solve the Smallest Subarrays With Maximum Bitwise OR problem.

Statement

Given an integer array nums of length n.

For each index i from 00 to n −1- 1, consider all possible subarrays starting at index i. Among all these subarrays, determine the minimum length of a subarray whose bitwise OR is equal to the maximum bitwise OR achievable by any subarray starting at i.

Return an integer array answer of length n, where answer[i] is the minimum length of such a subarray starting at index i.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9