I have not seen your code, but you must not be returning the provided char *binary from the declaration. The idea is to write TO *binary and then return that from the function... whether or not your code works on another IDE is meaningless if it's not set up the same as on codewars.
seems redundant ...
because it says "write to the binary string and return it":
given string
Please just forget the IDE, work only with the kata on the codewars site.
You do not need to, and thus should not, allocate memory. It has already been allocated for you in the provided pointer.
I have not seen your code, but you must not be returning the provided
char *binary
from the declaration. The idea is to write TO*binary
and then return that from the function... whether or not your code works on another IDE is meaningless if it's not set up the same as on codewars.because of the very next line(s) of code
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Currying
If you haven't solved it yet, you don't need to learn much for this. It's just about creating a good algorithm
It iterates over the string only once instead of three times, making it much faster.
If you aren't concerned with speed or space, the short code is nicer imo, since it's readability is better.