You are viewing a single comment's thread. Return to all comments →
def hackerlandRadioTransmitters(x, k): locations = sorted(x) station_location = first_house_outside_coverage = one_side_covered = two_side_coverage_counter = 0 while station_location < len(locations): station_location_0 = station_location while first_house_outside_coverage < len(locations) and locations[first_house_outside_coverage] <= locations[station_location] + k: first_house_outside_coverage += 1 if first_house_outside_coverage == station_location_0 + 1 or one_side_covered: station_location = first_house_outside_coverage two_side_coverage_counter += 1 one_side_covered = 0 else: station_location = first_house_outside_coverage - 1 one_side_covered = 1 return two_side_coverage_counter
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Hackerland Radio Transmitters
You are viewing a single comment's thread. Return to all comments →