What is wrong here

Why all my test cases are failing except sample one. I am unable to find the issue.

hello @atul51

the logic is wrong .
appending new digit in start or end will not ensure max.
try this case ->
1
3
23 5 4

use sort function and in that pass custom comparator
use this logic ->
return s1+s2 > s2+s1;
and then printr the final array

but after appending each time I am comparing if the value makes it a larger value or smaller. The largest is stored and moved forward to the next element. Can you please explain what is going wrong in my logic and input for which this will fail? I want to analyze this solution.

consider this is the input for the the corect output is 5423 but urs will give different

hI @aman212yadav Can you please help me with the java solution ?

check this

u can also use inbuilt sort function if u want