FastPrepFastPrep
Problem Brief

Count Subarrays with Bitwise OR Present

OA

Given an array of size up to 100000, count the number of subarrays for which the bitwise OR of all the elements of the subarray is present in that subarray itself. We need an efficient solution with O(n) or O(nlogn) time complexity.

1Example 1

Input
arr = [1, 6, 7]
Output
5
Explanation
🦇

2Example 2

Input
arr = [2, 4, 7]
Output
5
Explanation
🦕
public int countSubarraysWithBitwiseORPresent(int[] arr) {
  // write your code here
}
Input

arr

[1, 6, 7]

Output

5

Sign in to submit your solution.