У нас вы можете посмотреть бесплатно # 10.02.2026 [3719. Longest Balanced Subarray I] или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
10.02.2026 [3719. Longest Balanced Subarray I](https://leetcode.com/problems/longest...) medium [blog post](https://leetcode.com/problems/longest...) [substack](https://open.substack.com/pub/dmitrii...) [youtube]( • # 10.02.2026 [3719. Longest Balanced Subar... )  #### Join me on Telegram https://t.me/leetcode_daily_unstoppab... #### Problem TLDR Longes even=odd subarray #medium #hashset #### Intuition ```j // two pointers: we can't just blindly shrink/expand the window // pref mid suf // // 1 3 5 6 7 9 11 // o o o e o o o // which part to cut? // is this DP? big acceptance rate, probably brain teaser // the array size is small only 1500 // we can check every subarray in O(n^2) // build a prefix sum array // ok but how to deal with duplicates? // // 1 2 3 2 // 1 1 2 2 odds // 0 1 1 2 evens non-uniq // 0 1 1 1 evens uniq // * * will give wrong count for this range // // let's try write o(n^3), can't think of an optimal solution // TLE // as expected // 18 minute, go for hints; brute force? i litterally did that // ok maybe there is an O(N^2) brute-force possible? ``` From every position go to the end and count evens and odds. Mark visited with hashset. #### Approach use array instead of hashset array can be global if we mark visited values with current i #### Complexity Time complexity: $$O(n^2)$$ Space complexity: $$O(n)$$ #### Code https://dmitrysamoylenko.com/2023/07/...