Pergunta de entrevista da empresa Bloomberg

The assignment was to write a function that gets two characters arrays - the first is the string and the second is the substring - and removes all appearances of the given substring. Two restrictions: 1. Memory complexity is O(1) (Cannot change to String, cannot allocate memory for another array). 2. Cannot write a character in the same position more than once (naive solution doesn't fit against this limit).