Given two arrays of digits say A[] and B[], replace the digits in A with digits in B such that when you consider A as a number it is the largest possible. Digits in B cant be used more than once.

One solution I can think of is first sort B[ ] in descending order, then try to use B[0] to replace A[0], if B[0] is greater than A[0], replace it, otherwise compare B[0] and A[1] ... till we go through A or B is all used.