3 ms·
I see that and want to do it by appending backwards off the end of the string, then move the pointer to the new beginning. Is that "creating a new string"? Or j
by beat 13y ago
I see that and want to do it by appending backwards off the end of the string, then move the pointer to the new beginning. Is that "creating a new string"? Or just making a poopy on the floor for the garbage collector?
"Double the length of the old string and then cut it in half" isn't against the rules, right?
- bastiaanus 13y agoI don't know if it is against the rules, my approach was a recursive function.
- deleted 13y ago[deleted]
- beat 13y agoWell, yeah. That's the expected way to do it. My way has the benefit of bending the rule without breaking it. After all, we weren't told to not allocate memory, we were told to not create another string.
- deleted 13y ago[deleted]