Explanation:
7 digits in a number.
each digit of 5, 7, 9, 8 must be in it at least once.
but (as I understand it) no other digits can be used.
for the smallest number we start with the smallest digit for the highest ranked places, and then we fill up with the other 3 digits sorted by size low to high :
5555789
similarly, for the largest number we start with the largest digit for the highest ranked places, and then we fill up with the other 3 digits sorted by size high to low :
9999875