Tap here to switch tabs
Problem
Submissions

Problem: Count Good Subarrays

med
30 min
Try to solve the Count Good Subarrays problem.

Statement

Given an integer array nums, a subarray is called good if the bitwise OR of all elements in the subarray is present as an element within that same subarray.

Return the total number of good subarrays in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Good Subarrays

med
30 min
Try to solve the Count Good Subarrays problem.

Statement

Given an integer array nums, a subarray is called good if the bitwise OR of all elements in the subarray is present as an element within that same subarray.

Return the total number of good subarrays in nums.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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