- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Valid Parentheses Explained with a Stack #Shorts
Valid Parentheses is a classic LeetCode stack problem. Opening brackets go onto a stack, and each closing bracket must match the most recent opening bracket.
This corrected version has full burned-in word captions and audible background music.
Python idea:
stack = []
pairs = {')': '(', ']': '[', '}': '{'}
for c in s:
if c in pairs.values():
stack.append(c)
elif not stack or stack.pop() != pairs[c]:
return False
return not stack
Time: O(n)
Space: O(n)
#leetcode #python #javascript #algorithms #programming #codinginterview #stack #shorts
Видео Valid Parentheses Explained with a Stack #Shorts канала algorithmated
This corrected version has full burned-in word captions and audible background music.
Python idea:
stack = []
pairs = {')': '(', ']': '[', '}': '{'}
for c in s:
if c in pairs.values():
stack.append(c)
elif not stack or stack.pop() != pairs[c]:
return False
return not stack
Time: O(n)
Space: O(n)
#leetcode #python #javascript #algorithms #programming #codinginterview #stack #shorts
Видео Valid Parentheses Explained with a Stack #Shorts канала algorithmated
Комментарии отсутствуют
Информация о видео
Вчера, 12:09:13
00:00:59
Другие видео канала



