LeetCode HARD 3721 Longest Balanced Subarray II Summary
Generated by Codex with GPT-5
Quick facts
- Difficulty:
HARD - Problem: Longest Balanced Subarray II
- Topics:
Array,Hash Table,Divide and Conquer,Segment Tree,Prefix Sum
Problem gist
The input is an integer array. A subarray is balanced when the number of distinct even values inside it equals the number of distinct odd values inside it. Repeated copies of the same number only count once, so [3, 2, 2, 5, 4] has two distinct odd values, 3 and 5, and two distinct even values, 2 and 4.