J.P. Morgan Interview Question

Check the next permutation of number.