难度:简单
一、题目描述:
二、解题分析:
1、剑指解析
2、代码实现
class Solution:
def constructArr(self, a: List[int]) -> List[int]:
left = [1] * len(a)
right = [1] * len(a)
result = [1] * len(a)
for i in range(1, len(a)):
left[i] = left[i-1]*a[i-1]
for j in range(len(a)-2,-1,-1):
right[j] = right[j+1]*a[j+1]
for n in range(len(a)):
result[n] = right[n]*left[n]
return result