Error message in code

I have made my own logic to solve the problem. The link to code is: https://ide.codingblocks.com/s/353317
I’m getting the following error message. Kindly check my code. Thanks in advance.

hello @Divye-Aggarwal-3050062625037589

where u tried this?

it is working fine


.
see sometime dynamic allocation creates issue on cb compiler so if u r facing this issue again then declare static array (int arr[n] types ) instead of dynamic array

its working fine on my pc too but while submitting it, it shows error message as shown in the above image. Let me try through your static allocation.

Sir, I tried with static allocation. The code is compiling but all the test cases are failing now. Kindly help. Thanks in advance.
Link of my code: https://ide.codingblocks.com/s/353336

@Divye-Aggarwal-3050062625037589
bro u have made it bit complex .

this problem has very simple approach.

a)read all numbers as string and store them in array .
b) then sort them using custom comparator.
bool cmp(string a,string b){
return a+b > b+a;
}
c) print the array

1 Like

I completely agree with you and I will try with the method given by you but still I don’t see why my logic is failing. If you can point out the flaw then that would be very helpful for me. Thanks in advance.

@Divye-Aggarwal-3050062625037589
try ur code for this input->
1
4
20 4 300 0

1 Like

Got the flaw. Thanks. :+1:t2::100:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.