Company: Devrev_13nov
Difficulty: medium
Dominant Subarrays Problem Description You are given an array of N integers. A subarray is called dominant if at least one number appears K times or more within it. Your task is to count the number of such dominant subarrays in the given array. - You have an array of size N. - A subarray is a continuous part of the array (it cannot skip elements). - A dominant subarray is one where at least one number appears K times or more. - Your goal is to count how many such dominant subarrays exist. API Endpoints POST /api/dominantSubarrays Request Format The request body should be a JSON object containing the array size N, the minimum frequency K, and the array elements. { "N": 5, "K": 2, "arr": [1, 2, 1, 2, 1] } Response Format The response will be a JSON object containing the total number of dominant subarrays. { "count": 6 } Examples Sample Request { "N": 5, "K": 2, "arr": [1, 2, 1, 2, 1] } Sample Response { "count": 6 } Detailed Explanation for N=5, K=2, arr=[1, 2, 1, 2, 1] We are given N =