- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
LeetCode 238 – Product of Array Except Self | c++
Idea / How to Solve:
For each number in the array, we want the product of all other numbers.
Instead of multiplying every time:
1️⃣ Multiply all numbers before current index → call it left
2️⃣ Multiply all numbers after current index → call it right
3️⃣ Product for current index = left × right
We do this in two passes:
First pass → left products (left to right)
Second pass → right products (right to left, using a variable)
✅ This way, we get the answer for all indices without using division and in O(n) time.
Example:
nums = [1, 2, 3, 4]
Left products → [1, 1, 2, 6]
Multiply with right products → final = [24, 12, 8, 6]
#LeetCode #Coding #DSA #ProductOfArrayExceptSelf #Programming
Видео LeetCode 238 – Product of Array Except Self | c++ канала izumicode
For each number in the array, we want the product of all other numbers.
Instead of multiplying every time:
1️⃣ Multiply all numbers before current index → call it left
2️⃣ Multiply all numbers after current index → call it right
3️⃣ Product for current index = left × right
We do this in two passes:
First pass → left products (left to right)
Second pass → right products (right to left, using a variable)
✅ This way, we get the answer for all indices without using division and in O(n) time.
Example:
nums = [1, 2, 3, 4]
Left products → [1, 1, 2, 6]
Multiply with right products → final = [24, 12, 8, 6]
#LeetCode #Coding #DSA #ProductOfArrayExceptSelf #Programming
Видео LeetCode 238 – Product of Array Except Self | c++ канала izumicode
Комментарии отсутствуют
Информация о видео
10 января 2026 г. 18:08:50
00:11:31
Другие видео канала





















