Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Last active June 14, 2017 04:23
Show Gist options
  • Save tlkahn/01c304891e5aa6d7562feb0857a81811 to your computer and use it in GitHub Desktop.
Save tlkahn/01c304891e5aa6d7562feb0857a81811 to your computer and use it in GitHub Desktop.
hackerland-radio-transmitters
def solution(k, arr, origin=0):
arr.sort()
result = 1
cur = 0
origin = 0
for i in range(1, len(arr)):
if arr[i] - arr[origin] <= k:
pass
else:
origin = i - 1
j = 1
while origin + j < len(arr):
if arr[origin + j] - arr[origin] <= k:
pass
else:
origin = origin + j
i = origin + j + 1
result += 1
continue
j += 1
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment