Company: Air India

Difficulty: medium

Problem Statement

Racers Selection You are given the speeds of `n` racers in their original order. You may remove at most `k` racers. After removals, choose one contiguous segment of the remaining racers whose speeds are all equal. Print the maximum possible length of such a segment. Input The first line contains two integers `n` and `k`. The second line contains `n` integers, the racer speeds. Output Print one integer: the largest number of equal-speed racers that can be made contiguous after at most `k` removals. Constraints `1 <= n <= 3 * 10^5` and `1 <= k <= n`. Example Input `6 2` `1 4 4 2 2 4` Output `3` Notes Removing the two racers with speed `2` makes the three racers with speed `4` contiguous. The segment is contiguous after the removals, not necessarily in the original array.

More Air India OA questionsInterview experiences