leetcode_day07

 1 class Solution:
 2     def productExceptSelf(self, nums):
 3         output = []
 4         length = len(nums)
 5         for index1 in range(0, length):
 6             prod = 1
 7             for index2 in range(0, length):
 8                 if nums[index1] != nums[index2]:
 9                     prod = prod * nums[index2]
10             output.insert(index1, prod)
11             #print(result)
12             #output.append(result)
13         return output

猜你喜欢

转载自www.cnblogs.com/tommyngx/p/10480092.html