Such four-digit numbers can
(a) Contain all different digits, any four chosen from 1, 2, 3, 4 and 5 and arranged to form four digit number and this is done in 5P4 = 120 ways.
(b) Contain one repeated pair, the other two different, numbers like 1123, 3345, 3435, … and this is done in 5C1 x 4C2 x 4!/2! = 360 ways.
(c) Contain two repeat pairs, numbers like 1122, 1212, 3113, …, and this is done in 5C2 4!/2!2! = 60 ways.
Therefore, total number of numbers = 540.