MaxCounters optimized, and was able to answer all of the test cases flawlessly.
MaxCounters optimized, and was able to answer all of the test cases flawlessly.

Worst case complexity for previous code was O(N*M). Now it is O(N+M).

Result:
https://codility.com/demo/results/demoMKR6KY-55G/

mdunicorn/Codility,mdunicorn/Codility