Skip to content

Instantly share code, notes, and snippets.

@grubberr
Created March 26, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grubberr/3d57949f9314adc95decce2f76aca6c1 to your computer and use it in GitHub Desktop.
Save grubberr/3d57949f9314adc95decce2f76aca6c1 to your computer and use it in GitHub Desktop.
def counts(nums, maxes):
_nums = sorted(nums)
_maxes = sorted(maxes)
count = 0
res = {}
n = None
m = None
while True:
if n is None and _nums:
n = _nums.pop(0)
if m is None and _maxes:
m = _maxes.pop(0)
if n is not None and m is not None and n <= m:
count += 1
n = None
elif m is not None:
res[m] = count
m = None
if len(_maxes) == 0:
break
return [res[m] for m in maxes]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment