- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
LeetCode 761 | Special Binary String | Recursion + Greedy Sorting | Java | Hard
Today's LeetCode Daily
A special binary string has:
1. Equal number of 1s and 0s
2. Every prefix has at least as many 1s as 0s
Goal:
Rearrange the special substrings
to form the lexicographically largest string.
Approach Used:
Step 1:
Traverse the string and maintain a counter.
Increase for '1'
Decrease for '0'
Step 2:
Whenever count becomes 0,
we found a valid special substring.
Step 3:
Recursively process the inner substring
excluding the outer 1 and 0.
Step 4:
Wrap it again as:
1 + processed_inner + 0
Step 5:
Store all such special substrings in a list.
Step 6:
Sort the list in descending order
to make the final result largest.
Step 7:
Concatenate all substrings.
Key Idea:
Special binary strings behave like
balanced parentheses.
Use divide and conquer + greedy sorting.
Time Complexity: O(n log n) approx
Space Complexity: O(n)
Problem Link:
https://leetcode.com/problems/special-binary-string/description/?envType=daily-question&envId=2026-02-20
Java Solution (GitHub):
https://github.com/Amandf/LeetCode-Solutions-/blob/main/0761-special-binary-string/0761-special-binary-string.java
#leetcode #leetcodedailychallenge #java #recursion #greedyalgorithm #divideandconquer #dsa #codinginterview
Видео LeetCode 761 | Special Binary String | Recursion + Greedy Sorting | Java | Hard канала DRACO
A special binary string has:
1. Equal number of 1s and 0s
2. Every prefix has at least as many 1s as 0s
Goal:
Rearrange the special substrings
to form the lexicographically largest string.
Approach Used:
Step 1:
Traverse the string and maintain a counter.
Increase for '1'
Decrease for '0'
Step 2:
Whenever count becomes 0,
we found a valid special substring.
Step 3:
Recursively process the inner substring
excluding the outer 1 and 0.
Step 4:
Wrap it again as:
1 + processed_inner + 0
Step 5:
Store all such special substrings in a list.
Step 6:
Sort the list in descending order
to make the final result largest.
Step 7:
Concatenate all substrings.
Key Idea:
Special binary strings behave like
balanced parentheses.
Use divide and conquer + greedy sorting.
Time Complexity: O(n log n) approx
Space Complexity: O(n)
Problem Link:
https://leetcode.com/problems/special-binary-string/description/?envType=daily-question&envId=2026-02-20
Java Solution (GitHub):
https://github.com/Amandf/LeetCode-Solutions-/blob/main/0761-special-binary-string/0761-special-binary-string.java
#leetcode #leetcodedailychallenge #java #recursion #greedyalgorithm #divideandconquer #dsa #codinginterview
Видео LeetCode 761 | Special Binary String | Recursion + Greedy Sorting | Java | Hard канала DRACO
Комментарии отсутствуют
Информация о видео
20 февраля 2026 г. 10:53:33
00:03:11
Другие видео канала





















