will probably track down the length of the longest subarray of this cluster with the end goal that the most continuous worth in it isn't interesting. At the end of the day, you are searching for a subarray with the end goal that assuming the most successive worth happens f times in this subarray, something like 2 distinct qualities ought
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
You are given an exhibit [a1,a2,… ,an].
You will probably track down the length of the longest subarray of this cluster with the end goal that the most continuous worth in it isn't interesting. At the end of the day, you are searching for a subarray with the end goal that assuming the most successive worth happens f times in this subarray, something like 2 distinct qualities ought to happen precisely f times.
An exhibit c is a subarray of a cluster d if c can be gotten from d by erasure of a few (potentially, zero or all) components from the start and a few (conceivably, zero or all) components from the end.
Input
The primary line contains a solitary integer n (1≤n≤200000) — the length of the exhibit.
The subsequent line contains n integers a1,a2,… ,an (1≤
Output
You should output precisely one integer — the length of the longest subarray of the cluster whose most successive worth isn't novel. In case there is no such subarray, output 0.
Step by step
Solved in 4 steps with 1 images