# Product of Array Except Self

```python
class Solution:
    def productExceptSelf(self, nums):
        """
        :type nums: List[int]
        :rtype: List[int]
        """
        """
        Input:  [1,2,3,4]
        Output: [24,12,8,6]
        
        24 = 2 * 3 * 4
        12 = 1 * 3 * 4
        此題不能用除法
        
        [a, b,   c,         d]
         | /|  / |
        [1 1*a 1*a*b  1*a*b*c ]
        再倒著回來做一遍即可得到答案
        """
        p = 1
        res = []
        for i in range(0, len(nums)):
            output.append(p)
            p = p * nums[i]
        p = 1
        for i in range(n-1,-1,-1):
            output[i] = output[i] * p
            p = p * nums[i]
        return res
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zcjian.gitbook.io/project/array/product-of-array-except-self.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
