← All problemsSign in

2488. Count Subarrays With Median K

LeetCodeArrayHash TablePrefix SumOpen on judge ↗

You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k. Return the number of non-empty subarrays in nums that have a median equal to k. Note: - The median of an array is the middle element after sorting the array in ascending order. If the array is of even length, the median is the left middle element. - For example, the median of [2,3,1,4]

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start