- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Leetcode Problem 3445| Max Difference Between even and odd freq -II | Solution In Hindi | Java
🚀 Challenge Description:
Given a string s of digits ('0' to '4') and an integer k, find the maximum frequency difference freq[a] - freq[b] in any substring of s (length ≥ k) such that:
a occurs odd number of times
b occurs even number of times
Return the maximum such difference, or -1 if not possible.
💡 Key Constraints:
Substring must be at least k characters long
Characters a and b can be any digits, not necessarily distinct from each other
At least one valid (odd-even) pair is guaranteed
📘 Example 1
Input: s = "12233", k = 4
Valid: '1' → 1 (odd), '3' → 2 (even)
✅ Output: -1
📘 Example 2
Input: s = "1122211", k = 3
Valid: '2' → 3 (odd), '1' → 2 (even)
✅ Output: 1
📘 Example 3
Input: s = "110", k = 3
No valid (odd, even) pair
✅ Output: -1
🧠 Perfect for mastering:
Sliding window
Frequency analysis
Greedy thinking
🎯 Ideal for DSA prep, coding interviews, and problem-solving speedruns.
👇 Try it now and test your logic!
Видео Leetcode Problem 3445| Max Difference Between even and odd freq -II | Solution In Hindi | Java канала MissLogic - "Where code meets Clarity."
Given a string s of digits ('0' to '4') and an integer k, find the maximum frequency difference freq[a] - freq[b] in any substring of s (length ≥ k) such that:
a occurs odd number of times
b occurs even number of times
Return the maximum such difference, or -1 if not possible.
💡 Key Constraints:
Substring must be at least k characters long
Characters a and b can be any digits, not necessarily distinct from each other
At least one valid (odd-even) pair is guaranteed
📘 Example 1
Input: s = "12233", k = 4
Valid: '1' → 1 (odd), '3' → 2 (even)
✅ Output: -1
📘 Example 2
Input: s = "1122211", k = 3
Valid: '2' → 3 (odd), '1' → 2 (even)
✅ Output: 1
📘 Example 3
Input: s = "110", k = 3
No valid (odd, even) pair
✅ Output: -1
🧠 Perfect for mastering:
Sliding window
Frequency analysis
Greedy thinking
🎯 Ideal for DSA prep, coding interviews, and problem-solving speedruns.
👇 Try it now and test your logic!
Видео Leetcode Problem 3445| Max Difference Between even and odd freq -II | Solution In Hindi | Java канала MissLogic - "Where code meets Clarity."
Комментарии отсутствуют
Информация о видео
11 июня 2025 г. 15:36:31
00:27:16
Другие видео канала




















