I am not sure whether this is the right place to ask this question, but I am struggling to get to the right answer myself. I have done a programming test and I can not figure why my code fails in certain test cases.
The problem is that given an unsorted array of elements, e.g [1, 4, 2, 4] and an array of maximum, e.g [3,5], gives the solution of the count of elements in the first array that is less than the maximums in the second array. i.e [2, 4]
some example would be
inputs
nums = [2, 10, 5, 4, 8]
maxes = [3, 1, 7, 8]
outputs
solution = [1, 0, 3, 4]
inputs
nums = [1, 4, 2, 4]
maxes = [3, 5]
outputs
solution = [2, 4]
since there is one element is that is less than or equal to 3, and 0 element that is less than or equal to 1 and 3 element that is less than or equal to 3 and 4 element that is less than or equal to 8
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…