Given two unsorted arrays arr1[] and arr2[]. They may contain duplicates. For each element in arr1[] count elements less than or equal to it in array arr2[].
Input : arr1[] = [1, 2, 3, 4, 7, 9]
arr2[] = [0, 1, 2, 1, 1, 4]
Output : [4, 5, 5, 6, 6, 6]
Explanation: There are 4 elements less than or equal to 1 in second array, similarly there are 5 elements less than 2 in second array, calculate the values similarly for other elements.
Input : arr1[] = [5, 10, 2, 6, 1, 8, 6, 12]
arr2[] = [6, 5, 11, 4, 2, 3, 7]
Output : [4, 6, 1, 5, 0, 6, 5, 7]
Explanation: There are 4 elements less than or equal to 5 in second array, similarly there are 6 elements less than 10 in second array, calculate the values similarly for other elements.