I have the following problem:
You are given N counters, initially set to 0, and you have two possible operations on them:
The key is that [0] * N is an N operation. If that exists in a for loop it will become N*M. Tested in Codility 100%
# you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
def solution(N, A):
# write your code in Python 2.7
count = [0] * N
maxCounter = 0
minCounter = 0
for x in A:
if x <= N and x >= 1:
count[x-1] = max(count[x-1], minCounter) + 1
if maxCounter < count[x-1]:
maxCounter = count[x-1]
if x == N + 1:
minCounter = maxCounter
for i in xrange(N):
count[i] = max(count[i], minValue)
return count