Completes 18/22 timed out
This commit is contained in:
parent
976b6174eb
commit
c4be189687
@ -1,16 +1,19 @@
|
||||
from functools import reduce
|
||||
import operator
|
||||
|
||||
|
||||
def productExceptSelf(nums):
|
||||
"""
|
||||
:type nums: List[int]
|
||||
:rtype: List[int]
|
||||
"""
|
||||
numsProduct = []
|
||||
final = []
|
||||
for x in range(len(nums)):
|
||||
firstHalf = nums[:x]
|
||||
secondHalf = nums[(len(nums)-x):]
|
||||
if firstHalf:
|
||||
product = firstHalf + secondHalf
|
||||
numsProduct.append(product)
|
||||
|
||||
return numsProduct
|
||||
|
||||
temp = nums[0]
|
||||
del nums[0]
|
||||
final.append(reduce(operator.mul, nums))
|
||||
# print(nums)
|
||||
nums.append(temp)
|
||||
# print(final)
|
||||
return final
|
||||
print(productExceptSelf([1,2,3,4]))
|
||||
Loading…
Reference in New Issue
Block a user