Problem 3739 · Hard

Count Subarrays With Majority Element II

Map each value to +1 when it equals the target and -1 otherwise, then count subarrays whose balance is positive.

Open the interactive visualisation