题目描述
给定一个数组 A[0,1,…,n-1],请构建一个数组 B[0,1,…,n-1],其中 B 中的元素 B[i]=A[0]×A[1]×…×A[i-1]×A[i+1]×…×A[n-1]。不能使用除法。
示例:
输入: [1,2,3,4,5]
输出: [120,60,40,30,24]
提示:
所有元素乘积之和不会溢出 32 位整数
a.length <= 100000
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/gou-jian-cheng-ji-shu-zu-lcof
思路解析
已知
B i = A 0 × A 1 × ⋯ × A i − 1 × A i + 1 × ⋯ × A n − 1 B_i = A_0 \times A_1 \times \cdots \times A_{i-1} \times A_{i + 1} \times \cdots \times A_{n-1} Bi=A0×A1×⋯×Ai−1×Ai+1×⋯×</