The task is, you have an array of n numbers called nums, and an array of m numbers called maxes.
For each element in maxes, find the number of elements for which m is bigger than or equal to n.
nums = [4, 2, 5, 10, 8] maxes = [3, 1, 7, 8] output = [1, 0, 3, 4]
Eg, The first element, 3, in maxes, is only higher than 2 in nums, hence the first element in output is 1
The initial solution I could think of was trivial, and its O(n^2)
def sol_naive(nums,maxes): output =  for entry in maxes: higher_numbers = len([x for x in nums if x <= entry]) output.append(higher_numbers) return output
Wondering if there's a better approach to solve this problem?