Tap here to switch tabs
Problem
Submissions

Problem: Number of Subarrays With AND Value of K

Number of Subarrays With AND Value of K asks you to count nonempty contiguous subarrays whose bitwise AND of all elements equals the given target value.

Statement

Given an array of integers nums and an integer k, return the number of contiguous subarrays where the bitwise AND of all elements in the subarray equals k.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Subarrays With AND Value of K

Number of Subarrays With AND Value of K asks you to count nonempty contiguous subarrays whose bitwise AND of all elements equals the given target value.

Statement

Given an array of integers nums and an integer k, return the number of contiguous subarrays where the bitwise AND of all elements in the subarray equals k.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

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

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