Skip to content

Faster solution instead of array_unique() #1

@rvadym

Description

@rvadym

Ticket is related to this solution

// this can be also solved with 
// return count(array_unique($A));

This is result with array_unique()
https://codility.com/demo/results/demoATDHG8-X7Z/
Only 66% for Performance

But according to this article this task can be solved with native php functions keeping good Performance score

return count(array_flip(array_flip(array_reverse($A,true))));

;)

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