ByteDance Interview Question

Construct the largest number smaller than some number n given the digits in an array.