this does not account for the nul terminator (1 byte is missing)
char*res=(char*)malloc(strlen(od));
same remark
if(*s=='\0'){
return"";
the tests expect the returned string to be free()-able. "" is a string literal that cannot be freed
if(*od=='\0'){
char*cp=NULL;
strcpy(cp,s);
you are attempting to write at the null pointer here. this will crash. you have to allocate memory for `cp`.
your code passes once all these are fixed.
I'd try to reproduce it locally, at the very least you should be able to find out what inputs it happens for by printing (and flushing to ensure it isn't stuck in a buffer) and probably throw ASan or similar at it to see if it notices anything. Of course, it might be something unexpected going on in the test code that you can't reproduce yourself - for which I suppose very carefully finding out how your function should behave is a start.
When i run your code against the tests and print out the indata, it turns out it does happen for an obviously special test case, so there's a good chance you don't need to dig any further than that.
thanks for the thorough answer!
the tests expect the returned string to be
free()
-able.""
is a string literal that cannot be freedto easy for 6 kyu
the word "java" is not similar to "heaven".
dealing with decimals here and in similar katas feels like a pain in the ass
this is the base
A really good solution!
The famous C++'s "Unsafe memory" ))
wtf ???
are you kidding me or what?
great series of katas! thank you!
very good kata
lousy kata, no higher than 8 kyu
I'd try to reproduce it locally, at the very least you should be able to find out what inputs it happens for by printing (and flushing to ensure it isn't stuck in a buffer) and probably throw ASan or similar at it to see if it notices anything. Of course, it might be something unexpected going on in the test code that you can't reproduce yourself - for which I suppose very carefully finding out how your function should behave is a start.
When i run your code against the tests and print out the indata, it turns out it does happen for an obviously special test case, so there's a good chance you don't need to dig any further than that.
This comment is hidden because it contains spoiler information about the solution
Loading more items...