my test case 0 answer is correct still it is being shown as wrong and other test cases are showing run errors.
Why is my code not working?
hi @Manvik-Arya-4391661007540658, you are getting runtime error because you are not handling the case when ‘i’ can exceed the string size inside the comparator function in your while loop. so you have to put a condition i<first.size() in your while condition.
refer the corrected code :- https://ide.codingblocks.com/s/261939
with this you will be saved from runtime error , but your logic for your code is not correct.
consider examples like
2
2
9 998
Your code output :- 9989 (998+9)
correct output :- 9998 (9+998)
3
5 35 353
your code output :- 535335 (5+353+35)
correct output :- 535353 (5+35+353)
give it a try to figure out logic to handle these cases , In case you face any trouble feel free to ask , i will provide you the answer
okay thanks i’ll think of another logic
@Manvik-Arya-4391661007540658, your code is correct , just some small mistakes
- print answer for every testcase in a single line , use endl after printing ans.
- don’t use stoi as a[i] can be large as 10^5 so concatination two integers will give you 10^10 size integer which might give you runtime
corrected code :-