Skip to content

Solution for MaxProductOfThree Wrong #6

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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