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.
defhackerlandRadioTransmitters(x,k):transms=1x.sort()currentIdx=0centerCandidatePos=x[currentIdx]+kantennaPos=currentIdxwhilecurrentIdx<len(x):ifx[currentIdx]<=centerCandidatePos:antennaPos=x[currentIdx]#findactualantennapositionclosesttocenterelifx[currentIdx]>antennaPos+k:# we've moved to a house outside of current range, next candidatecenterCandidatePos=x[currentIdx]+ktransms+=1currentIdx+=1returntransms
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Hackerland Radio Transmitters
You are viewing a single comment's thread. Return to all comments →