The output of A

Input-
: [ 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 ]

I solved this but I am getting-
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 52 16 84 98 103 116 128 142 153 158 160 164 165 190 202 205 208 213 226 241 247 265 274 285 311 312 315 319 321 335 351 363 365 417 422 448 460 469 472 488 499 507 515 526 606 626 669 681 693 695 701 708 734 747 784 822 846 856 908 916 952 961 975

But your output is showing
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

If you check the last four numbers in the input - 701, 319, 695, 52 -> the next bigger number would be 701, 695, 52, 319.
The increasing order of numbers would be

  1. 701 52 319 695
  2. 701 52 695 319
  3. 701 319 52 695
  4. 701 319 695 52
  5. 701 695 52 319
  6. 701 695 319 52
    You have been given the fourth number here. You need to output the fifth

For this 701, 319, 695, 52
next greater is 701 52 319 695

I am also getting the same output. There is some discrepancy in the question, what are they asking and what are they expecting

Click here to start solving coding interview questions