Emergent | Feb 2026 | Count Nice Subarrays
Question · Posted Apr 2026
Problem Statement: Count Nice Subarrays The Objective: Given an array of integers nums and an integer k, find the total number of continuous subarrays that are nice. A subarray is considered "nice" if it contains exactly k odd numbers. Example 1: k = 3 nums = [1, 1, 2, 1, 1] Analysis: Subarray [1, 1, 2, 1] has 3 odd numbers. Subarray [1, 2, 1, 1] has 3 odd numbers. Result: 2 nice subarrays.
The full answer & interview discussion are available to premium members.
Log in Create a free account