Web Projects Outsourcing

MaxCounters Demo Task at Codility.com

codility netbeansLesson 2 – Counting Elements – MaxCounters (max_counter) demo task solution code written in php. Gives 100/100 score at the time of publishing. The description of the problem is copyrighted, so please see the following link for it: https://codility.com/demo/take-sample-test/max_counters

Solution in php:

Given “AS IS”, can be ported from other languages from solutions found on the internet, please use with care.

Please note: we think that codility.com does not give a correct assessment of your real-world programming skills. For instance, reading the below would bring more understanding why: http://codility-test-questions.blogspot.com/2013/01/my-experience-with-codility-test.html

One thought on “MaxCounters Demo Task at Codility.com

  1. Jo

    Here’s my solution but it only scored 60% on performance. I can’t work out why. Is array_fill() the issue?

    function solution($N, $A) {
    $len = count($A);
    $B = array_fill(0, $N, 0);

    for ($i=0;$i<$len;$i++) {
    if ($A[$i]==$N+1) {
    $B = array_fill(0, $N, max($B));
    } else {
    $B[$A[$i]-1]++;
    }
    } return($B);
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × two =