Untitled
class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: if not nums: return nums forwards = [1] backwards = [1] for i, j in zip(nums[:-1], reversed(nums[1:])): forwards.append(forwards[-1]*i) backwards.append(backwards[-1]*j) return [forwards[i]*backwards[len(backwards)-1-i] for i in range(len(nums))]