构建乘积数组-python

思路:参考https://blog.csdn.net/u010005281/article/details/80200398

# -*- coding:utf-8 -*-
class Solution:
    def multiply(self, A):
        # write code here
        B = [1]*len(A)
        for i in range(len(A)):
            mult = mult*A[i-1] if i >0 else 1
            b = 1
            for ii in range(i+1, len(A)):
                b *= A[ii]
            B[i] = mult*b
        return B
posted @ 2019-08-11 20:02  Dolisun  阅读(269)  评论(0编辑  收藏  举报