MaxCounter Codility Test Explained – Full Explanation Tutorial for Max Counters | Python Learning

preview_player
Показать описание
Everything explained! This one is a doozy, marked “respectable”, but we break it apart starting with low performance scores and work our way up to what makes it 100% piece by piece. Enjoy!

_________________________________________

_________________________________________

"Whoever gives heed to instruction prospers, and blessed is the one who trusts in Yahweh."
--Prov. 16:20

#maxcounters #codility #python
Рекомендации по теме
Комментарии
Автор

I had no clue what the question was asking until watching this video.

MarsLanding
Автор

Glad I could help you with this one, mom!

helanabrock
Автор

Hello,

If you put a check in place to stop unnecessary array creations you get 100% performance, my solution was very similar to yours.

def solution(N, A):
result = [0]*N
just_reset = False
m = 0

for i in A:
if i <= N:
new = result[i-1] + 1
result[i-1] = new
if new > m:
m = new
just_reset = False
elif not just_reset:
result = [m]*N
just_reset = True

return result

sulamanahmad
Автор

Thank you so much for making this video and explaining the problem so clearly.

gloriabernard