Created
March 26, 2017 17:12
-
-
Save grubberr/3d57949f9314adc95decce2f76aca6c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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