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.
Examples
01 · Example 1
arr = [1, 6, 7] return = 5
🦇
02 · Example 2
arr = [2, 4, 7] return = 5
🦕
More Microsoft problems
- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
- Distinct Number Line MovesOA · Seen Oct 2025
- Get Minimum TimeSeen Jun 2025
- Get Max Or SumSeen Jun 2025
public int countSubarraysWithBitwiseORPresent(int[] arr) {
// write your code here
}
arr[1, 6, 7]
expected5
sign in to submit