Codility Lesson 04 (missing exercise)
Introduction
Let’s finish the final problem of the section 4.
Lesson 04-a: PermCheck
Problem URL: https://codility.com/programmers/task/max_counters/
Exercise URL: https://codility.com/demo/take-sample-test/max_counters/
Solution
A developing pattern now!! What it would be? After reading the exercise letter the first pattern that came to my mind was Command pattern.
Clearly, there is not one-to-one relation with the pattern and the problem, but if we analize it we have a group of actions/command to execute given by the input array A and data structure over
which those command will take effect.
If you think that make sense, the command are really simple, reset the data structure (the result array) with the max founded value, and the an item of the output array.
Honestly I do not know why this problem is in the “respectable” category.
Code
1 | function solution (N, A) |