Wrong ans for given test case


#1

For test case --> A : [ 444, 994, 508, 72, 125, 299, 181, 238, 354, 223, 691, 249, 838, 890, 758, 675, 424, 199, 201, 788, 609, 582, 979, 259, 901, 371, 766, 759, 983, 728, 220, 16, 158, 822, 515, 488, 846, 321, 908, 469, 84, 460, 961, 285, 417, 142, 952, 626, 916, 247, 116, 975, 202, 734, 128, 312, 499, 274, 213, 208, 472, 265, 315, 335, 205, 784, 708, 681, 160, 448, 365, 165, 190, 693, 606, 226, 351, 241, 526, 311, 164, 98, 422, 363, 103, 747, 507, 669, 153, 856, 701, 319, 695, 52 ]
The answer given is

444 994 508 72 125 299 181 238 354 223 691 249 838 890 758 675 424 199 201 788 609 582 979 259 901 371 766 759 983 728 220 16 158 822 515 488 846 321 908 469 84 460 961 285 417 142 952 626 916 247 116 975 202 734 128 312 499 274 213 208 472 265 315 335 205 784 708 681 160 448 365 165 190 693 606 226 351 241 526 311 164 98 422 363 103 747 507 669 153 856 701 695 52 319

but the correct ans should be

444 994 508 72 125 299 181 238 354 223 691 249 838 890 758 675 424 199 201 788 609 582 979 259 901 371 766 759 983 728 220 16 158 822 515 488 846 321 908 469 84 460 961 285 417 142 952 626 916 247 116 975 202 734 128 312 499 274 213 208 472 265 315 335 205 784 708 681 160 448 365 165 190 693 606 226 351 241 526 311 164 98 422 363 103 747 507 669 153 856 701 52 319 695
since this is the next immediate permutation.

Please fix the expected result of test case


#2

Yes, Can someone kindly get back on this? This is a wrong test case. Also the test case given in question as well is wrong:

Input 4:
    A = [20, 50, 113]

Output 4:
    [20, 113, 50]

Instead of the given output, it should have been

[50, 113, 20]


#3

Expected Output Is Wrong.


#4

I have also got the same error,


#5

Same error. Please correct this.


#6

Actually, It’s correct. Maybe you guys are replacing 319 with 52 (the smallest element) and then sorting the remaining array (which lies after that).
Instead, we have to replace 319 with the next greater number, i.e. 695 in this case and then sort it.
So it will be [. . . 701, 319, 695, 52] --> [. . . 701, 695, 319, 52] -->[. . . 701, 695, 52, 319] which is the required answer.