I’m getting a run error in test case #2. Test case #1 is Correct. Link to the code is
https://ide.codingblocks.com/s/138939
Getting error in string sort problem
run error is due to
s[n]
don’t do this type of memory allocation
either gave it size or allocate dynamically
Why Should I not do this type of memory allocation? How should i do it then?
this is depend on the judge compiler if there is enough memory it can allocate otherwise not so there can be problem some time
either do s[1000]
or
string *s=new string[n]
Using heap still gives a run-error, and by using s[1000] it shows a Wrong answer on Test case 2
in ur custom function u r making wrong comparision
suppose a=zyabcgysd b=abc
now u are checking if a[i]!=b[i] return a<b
but here b is smaller than the a
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.