the program is showing a runerror while submission, i tried to execute in an online compiler and it worked just fine
runError while compiling fine
Sample test case:
1
56
961 925 815 342 102 70 864 753 610 148 422 209 350 481 485 885 850 41 78 688 816 104 651 475 61 89 244 194 708 184 512 888 116 386 728 884 874 124 456 776 730 905 95 359 90 264 607 511 261 788 536 581 463 504 200 402
10
512 850 184 244 264 485 815 261 961 124
Your code gives nullpointer exception for this test case.
https://ide.codingblocks.com/s/228817 I have corrected your code but its still giving this error.
Don’t sort the array before construction. While constructing pass the array elements one by one.