Skip to content

Solution for MaxProductOfThree Wrong #6

@embedded4ever

Description

@embedded4ever

Hi, looks like your code gives %100 results on the codility test cases. But there is a mistake.

Let's say our input is that :

vector vec = {-2, -1, 0 , 4};

According to your code, function returns 0 because of this line :

if ( A[2] == 0 ) return A[0] * A[1] * A[2];

i think , it should be something like this

if ( A[2] == 0 ) return A[0] * A[1] * A[3];

it gives 8.

Such a test scenario may not have come across on the Codility site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions