You are viewing a single comment's thread. Return to all comments →
def hackerlandRadioTransmitters(x, k) x.sort! counter = 0 last_uncovered = 0 last_transmitter = -1 1.upto(x.length-1) do |i| if x[i] - x[last_uncovered] > k and last_transmitter == -1 last_transmitter = i-1 counter +=1 end if last_transmitter != -1 and x[i]-x[last_transmitter] > k last_uncovered = i last_transmitter = -1 end end counter += 1 if last_transmitter == -1 counter end
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 →
Ruby