• 48.0%

https://leetcode.com/problems/product-of-array-except-self/#/description

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

Solve it without division and in O(n).

Could you solve it with constant space complexity? (Note: The output array does not count as extra space for the purpose of space complexity analysis.)

https://discuss.leetcode.com/topic/20434/o-n-time-and-o-1-space-c-solution-with-explanation

O(n) time and O(1) space C++ solution with explanation

First, consider O(n) time and O(n) space solution.

We just need to change the two vectors to two integers and note that we should do multiplying operations for two related elements of the results vector in each loop.

https://discuss.leetcode.com/topic/37927/how-from-o-n-to-o-1

How from O(N) to O(1)

Here is the O(N) based C++ implementation

How to use O(1) ?

By observing the above code, we can just for every position multiply it to its right position.

Just the idea to think reversly !

https://discuss.leetcode.com/topic/18877/my-c-solution-o-n-time-with-no-extra-space

My C++ solution, O(n) time with no extra space

https://discuss.leetcode.com/topic/18983/python-solution-accepted-o-n-time-o-1-space

Python solution (Accepted), O(n) time, O(1) space

https://discuss.leetcode.com/topic/30115/very-easy-two-passes-solution

Very easy two passes solution