Company: DevRev_24aug
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. Function Description: You must implement the function countDominantSubarrays . Parameters: int N : The number of elements in the array. int K : The minimum required frequency for a number to make a subarray dominant. int[] arr : An array of size N , containing the elements. Returns: int : The total number of dominant subarrays in the given array. Examples Example 1: Input: N = 5, K = 2, arr = [1, 2, 1, 2, 1] Output: 6 Explanation: We need to count all subarrays where at least one number appears 2 times or mo