Problem · Array
Count Subarrays with Bitwise OR Present
Learn this problemProblem statement
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.
Function
countSubarraysWithBitwiseORPresent(arr: int[]) → longExamples
Example 1
arr = [1, 6, 7]return = 5🦇
Example 2
arr = [2, 4, 7]return = 5🦕
Constraints
1 <= arr.length <= 100,000- Each element fits in a signed 32-bit integer.
More Microsoft problems
- Authentication SystemOA · Seen Jul 2026
- Binary String Swap TimeOA · Seen Jul 2026
- Minimum Effort Task ScheduleOA · Seen Jul 2026
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026