Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
1 like 0 dislike
2,856 views
in Online Assessments by Expert (34,270 points) | 2,856 views

1 Answer

1 like 0 dislike
You are given an array and an integer k and an array of integers. You must find the length of longest contigous subarray where all integers are equal after removing at most k elements from the array.

 

Example
Input:
[1, -2, 1, 1, 3, 2, 1 ,-2] k = 3
Output: 4

 

Explanation:
Remove index 1 from original Array:
[1, 1, 1, 3, 2, 1, -1]
Remove index 4 from original Array:
[1, 1, 1, 2, 1, -1]
Remove index 5 from original Array:
[1, 1, 1, 1, -1]

 

4 because the subarray with the same number has length of 4.
by Expert (34,270 points)