Compute the maximum product of all entries but one - assumed result with input A.size() == 1

#1

[Problem 25.4 EPIJ v 2.0.0]

Just a small note to the problem statement, when input is an array of size 1, the algorithm returns 1 (e.g. int product = 1;).
It might be a fairly reasonable return value, but there is no restriction given like “following has to be true: A.size() > 1” as far as I can see.

My own implementation returned same value (unintentionally coded), were just able to observe it through a unit test. I guess such one is easy to overlook.

0 Likes

#2

Hi @Artem,

Thanks for this discussion, and I think what you meant making sense. It is not well-defined in the case of array size is 1. We will mention this in the next edition.

0 Likes