Microsoft | Phone | Minium swap to get repeated subarray

Given an array with around 10w elements, each element is within [0,10w], how to get max subsequense length with same value if you have a opportunity to swap two elements?

Samples:
1,1,0,2,3,1,0,1,1,3,4 => output: 4
0,2,3,1,0,1,1,3,4 => output: 3
1,1,0,0,2,3,3,1 => output: 3

Comments (6)