Find the largest number smaller than n using a specific set of digits
Given a set of available digits (1-9) and a target number n, find the largest number that can be constructed using only those digits (with repetition allowed) such that the resulting number is strictly less than n.
Examples:
- Available digits: {1, 2, 9, 4}, n = 2533 $\rightarrow$ Result: 2499
- Available digits: {1, 2, 5, 4}, n = 2543 $\rightarrow$ Result: 2542
- Available digits: {1, 2, 5, 4}, n = 2541 $\rightarrow$ Result: 2525
- Available digits: {1, 2, 9, 4}, n = 2111 $\rightarrow$ Result: 1999
- Available digits: {5, 9}, n = 5555 $\rightarrow$ Result: 999