Hi, In version 1.5.7, problem 7.4 (REPLACE AND REMOVE), the introduction said there is a very straightforward implementation if the function can allocate O(n) extra space, where n is the size of the input string.
Shouldn’t that read O(2n) extra space? If you can only allocate O(n) extra space and the input string is completely full of ‘a’ characters, you are still going to have to play tricks with writing backwards and in-place etc.
On the other hand if you can allocate O(2n) extra space you can just zoom through in one pass copying (or not) the proper characters to the output string.
Am I understanding this correctly? The problem solution also says it is trivial if we can write to a new string, but it doesn’t elaborate on the size of that new string.
Thanks!