How to get the maximum and minimum of length $m$ and the sum of the digits $s$
By example:
Length: 2 Sum of its digits: 15
Max: 96, Min: 69
Length: 2 Sum of its digits: 2
Max: 20, Min: 11
How to get the maximum and minimum of length $m$ and the sum of the digits $s$
By example:
Length: 2 Sum of its digits: 15
Max: 96, Min: 69
Length: 2 Sum of its digits: 2
Max: 20, Min: 11
Copyright © 2021 JogjaFile Inc.
The basic answer is for the maximum you need all the big numbers up front and for the minimum you need all the little numbers up front. For the max, fill from the left with nines as far as they go, the remainder (if any) in the next digit, and finish with zeros. For the min, fill from the right with nines, then the remainder, then zeros, saving a $1$ for the lead digit.