Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Nice Subarrays

Count Number of Nice Subarrays asks you to count contiguous subarrays in an integer array that contain exactly a given number of odd values, then return the total.

Statement

Given an integer array nums and an integer k, return the number of contiguous subarrays of nums that contain exactly k odd numbers.

Note: A subarray is a contiguous sequence of elements within nums.

Constraints:

  • 1≤1 \leq nums.length ≤50000\leq 50000

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Nice Subarrays

Count Number of Nice Subarrays asks you to count contiguous subarrays in an integer array that contain exactly a given number of odd values, then return the total.

Statement

Given an integer array nums and an integer k, return the number of contiguous subarrays of nums that contain exactly k odd numbers.

Note: A subarray is a contiguous sequence of elements within nums.

Constraints:

  • 1≤1 \leq nums.length ≤50000\leq 50000

  • 1≤1 \leq nums[i] ≤105\leq 10^5

  • 1≤1 \leq k ≤\leq nums.length