Pergunta de entrevista da empresa ByteDance

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