from my side all test case is running please tell which test cases is not passed
Please tell which test case is not running
I HAVE CHANGED THE TYPES NOW TLE IS COMING KINDLY HELP
@1999atrijsharma Hi buddy, so first n^2 approach is not gonna work here, secondly try for this simple test case:
1
2
9 98
your answer - 989
correct - 998
Hint 1 :- Try to use an anonymous comparator, If you donβt know about it then study about it
Hint 2 :- You have to compare x + y string with y + x string and sort on that basis.
i have resolved all issues now can u please help me out with TLE
sir please reply as i have to complete this problem??
@1999atrijsharma bro you are not moving in right direction here,
natural order sorting will not work here.
Sample Input -
1
4
9 42 98 7
Check on this case!
Also i am attaching two approaches for your reference non optimized and optimized one.
The question is not that complicated. you will learn many things from these approaches.
The approaches are based on this idea -
The idea is to use any comparison based sorting algorithm. In the used sorting algorithm, instead of using the default comparison, write a comparison function myCompare() and use it to sort numbers. Given two numbers X and Y, how should myCompare() decide which number to put first β we compare two numbers XY (Y appended at the end of X) and YX (X appended at the end of Y). If XY is larger, then X should come before Y in output, else Y should come before. For example, let X and Y be 542 and 60. To compare X and Y, we compare 54260 and 60542. Since 60542 is greater than 54260, we put Y first.