Maximum product of all entries but one: you need only one array

#1

Hi guys,

in the solution with 2 additional arrays, right array is enough. The left one can be computed as we go using a single variable to accumulate the left product.

It doesn’t change O(n) space complexity, but saves a bit of space and 4-5 lines.

Regards.

0 Likes

#2

Hey @damluar,

Thanks for this cool idea, and it is definitely not necessary. I think the reason I added before is for readability. However, I think proper comment shall still be able to preserve the readability and make the code more succinct.

0 Likes