Google Mock Interview

Anonymous User
1195
Mar 30, 2025

We are given an array A consisting of N integers. In one move, we can choose any element in this array and replace it with any value.

We are interested in the longest consistent segment of identical elements. For example, given an array A = [3, -3, 3, 3, 3, 1, -3], the segment that we are looking for is [3, 3, 3].

What is the maximum length of such a segment that we can achieve by performing at most three moves on the array?

Comments (13)