Problem 3721 · Hard

Longest Balanced Subarray II

A subarray is balanced when it has the same number of distinct even values and distinct odd values. Find the longest balanced subarray.

Open the interactive visualisation