- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
The Dutch National Flag Problem
The Dutch National Flag algorithm lets you arrange/sort a list in O(n) time and O(1) space given the elements of the list are limited to being one of three unique values.
Algorithm Steps:
1. Initialise low and mid pointing to the first element of the list, and high pointing to the last element. Let middle be the middle element of the three values.
2. While mid is less than or equal to high:
2a. If nums[mid] == middle, increment mid.
2b. If nums[mid] is greater than middle, swap nums[mid] and nums[high] and decrement high.
2c. If nums[mid] is less than middle, swap nums[mid] and nums[low] and increment both low and mid.
Видео The Dutch National Flag Problem канала emcapsulation
Algorithm Steps:
1. Initialise low and mid pointing to the first element of the list, and high pointing to the last element. Let middle be the middle element of the three values.
2. While mid is less than or equal to high:
2a. If nums[mid] == middle, increment mid.
2b. If nums[mid] is greater than middle, swap nums[mid] and nums[high] and decrement high.
2c. If nums[mid] is less than middle, swap nums[mid] and nums[low] and increment both low and mid.
Видео The Dutch National Flag Problem канала emcapsulation
Комментарии отсутствуют
Информация о видео
1 февраля 2025 г. 14:11:02
00:01:16
Другие видео канала





















