作者:
Rushia (みけねこ的鼻屎)
2024-03-15 10:08:58https://leetcode.com/problems/product-of-array-except-self/
238. Product of Array Except Self
給你一個陣列nums,求出一個列表ls,ls[i] = 除了nums[i]以外的所有元素內積。
思路:
1.ls[i] = (0~i-1的積) * (i+1~n-1的積),遍歷一次用一個陣列紀錄左邊的積,在遍歷
一次從右到左,過程紀錄右邊的積,並把右邊的積乘上左邊的就好