The answer is the difference between the largest and smallest number in each digits.
6 4 2 5 9
4 9 8 5 7 (-)
- -
2 5 6 0 2 ( Subtract Big - small number in each unit's , ten's , 100's place etc.)
- -
Similarly, on the given prb,
9 8 6 5 4
2 4 3 1 8 (-)
7 4 3 4 4
Answer is 74344