Don't understand expected output

I’ve got input [319, 695, 52]. Expected result - [695, 52, 319].
Why not [52, 319, 695]? If we sort these numbers we will get [31969552, 52319695, 69552319], isn’t it? So [52, 319, 695] should be next permutation. Do I understand correctly, what permutation is?

No, you shouldn’t concatenate the numbers into one. Just use their real value to order them.

so in the input you gave, first permutation is : [52,319,695]
second is : [52,695,319] , … and last permutation is: [695,319,52]

1 Like

Thank you. I’ve understood the idea

Click here to start solving coding interview questions