Тёмный

LEETCODE 238 (JAVASCRIPT) | PRODUCT OF ARRAY EXCEPT SELF 

Andy Gala
Подписаться 7 тыс.
Просмотров 4,2 тыс.
50% 1

Hey everyone. Check out this in-depth solution for leetcode 238.

Опубликовано:

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 8   
@dawsoncontreras6400
@dawsoncontreras6400 2 года назад
Best explanation I found thanks
@sajalgupta7345
@sajalgupta7345 2 года назад
Great Explanation. One small thing to confirm: Line 12, it should be left.length ??
@sinxenon3181
@sinxenon3181 Год назад
thanks! a tricky task!
@FlynnaBagel
@FlynnaBagel 2 года назад
why do we want to start the left most index value to 1? and the right most index value to 1?
@kromefish
@kromefish 2 года назад
It's a work around to make this solution work. There is no index - 1 value to generate the first element in the left array and, conversely, there is no index + 1 value to generate the last element in the right array.
@underemployed7136
@underemployed7136 11 месяцев назад
/** * @param {number[]} nums * @return {number[]} */ var productExceptSelf = function(nums) { let left =1; let right=1; const result=new Array(nums.length).fill(1); for(let i=0;i
@nier3434
@nier3434 Год назад
the O(1) in javascript: function productArray(array) { const acc = 0 console.log(array); return array.map((_, i) => array.reduce((total, value, j) => { console.log(total, i, j, value, (total * value)); return acc + total * (i === j ? 1 : value); }, 1)) };
@ghanashrim2839
@ghanashrim2839 Год назад
it's O(n^2) map and reduce functions are like loops, so it'll be n*n
Далее
LEETCODE 977 (JAVASCRIPT) | SQUARES OF A SORTED ARRAY
10:29
LEETCODE 146 (JAVASCRIPT) | LRU CACHE
17:42
Просмотров 4,4 тыс.
LEETCODE 21 (JAVASCRIPT) | MERGE TWO SORTED LISTS
14:29
Product of array except self | Leetcode #238
15:00
Просмотров 95 тыс.