Company: Adobe_13_dec
Difficulty: medium
Good Subarrays body { font-family: sans-serif; line-height: 1.6; margin: 20px; } h1 { color: #333; } h2 { color: #555; border-bottom: 1px solid #eee; padding-bottom: 5px; margin-top: 20px; } pre { background-color: #f4f4f4; padding: 10px; border-radius: 5px; overflow-x: auto; } code { font-family: monospace; background-color: #f0f0f0; padding: 2px 4px; border-radius: 3px; } ul { list-style-type: disc; margin-left: 20px; } p { margin-bottom: 10px; } Good Subarrays Problem Description Given an integer array arr[] of size n . Your task is to count the number of good subarrays of the given array arr . Here any subarray arr[L...r] is considered to be good if it satisfies the golden condition. Golden condition for a subarray arr[L...r] is that the subarray should have exact X elements in the subarray that have occurred at least 3 times in the subarray. Note: Subarray arr[L...r] contains all elements arr[L], arr[L+1]...arr[r] . Example 1 Input: n=6 arr={1,2,2,2,1,1} X=2 Output: 1 Explanation: