Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew 🚀
Contest SolutionsPractice
Practice Sheets
MasterclassesLive 👨🏻‍💻

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
© 2026coding75•crackDSA™•Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021•Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/LeetCode/Biweekly Contest 134/3209. Number of Subarrays With AND Value of K
Prev
LeetCodeLeetCode
Hard
Biweekly Contest 134

3209. Number of Subarrays With AND Value of K

MathBit ManipulationBitmaskArray
Loading...
Solve on LeetCode

Problem Statement

Official algorithmic problem description and constraints.

Open on LeetCode

Given an array of integers nums and an integer k, return the number of 

subarrays

ofnumswhere the bitwiseANDof the elements of the subarray equalsk. 

Example 1:

Input: nums = [1,1,1], k = 1

Output: 6

Explanation:

All subarrays contain only 1's.

Example 2:

Input: nums = [1,1,2], k = 1

Output: 3

Explanation:

Subarrays having an AND value of 1 are: [1,1,2], [1,1,2], [1,1,2].

Example 3:

Input: nums = [1,2,3], k = 2

Output: 2

Explanation:

Subarrays having an AND value of 2 are: [1,2,3], [1,2,3].

 

Constraints:

  • 1 <= nums.length <= 105
  • 0 <= nums[i], k <= 109


Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Biweekly Contest 134
Previous Problem