Wrong test case or did i get the question wrong?


#1

Your Input: 3 59 854 422
Expected output is 422 59 854

How is this greater than the input?


#2

The input is combination of numbers in array rather than being a single number.
Look at this array {59, 854, 422} in order of their values, which is {1, 3, 2}, as 59(1) is smaller than 422(2) is smaller than 854(3).
Now, if you rearrange {1, 3, 2}, you get {2, 1, 3} as next greater combination, which represents {422, 59, 854}.


#3

@ samnamdeo your explanation is good but according to the question the output value is numerically greater then input which is not true in this test case.