We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
this problem easily could be awarded with 100 points or even promoted as hard.
there are many things to consider:
build ranges of availability for every preschooler
think about situation where ranges are overlapping in cycles
walk twice around a table to close all cyclest
defsolve(t):ranges,n=[],len(t)fori,einenumerate(t):ife>=nore==0:# skip those who need to much time# and those who had done their drawingcontinue# add range from start (second value is 0) to end (is 1)ranges.extend([((i-n+1+n)%n+1,0),((i-e+n)%n+1,1)])ranges.sort(key=lambdae:(e[0],e[1]))# max opened ranges, currently open ranges# and first index of max opened range max_,current,first_index=0,0,1for_inrange(2):# walk twice arround a tablefori,vinranges:ifmax_==current:first_index=min(i,first_index)# get lowest index for all maxesifv==0:# beginning of rangecurrent+=1ifmax_<current:max_=currentfirst_index=i# set new first indexelse:current-=1returnfirst_index
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Kindergarten Adventures
You are viewing a single comment's thread. Return to all comments →
this problem easily could be awarded with 100 points or even promoted as hard.
there are many things to consider: