2019-04-16, 11:21 AM
This is what I meant by it depending on how many spaces there are. My code always runs in O(n) - it doesn't matter how long the string is, nor how many duplicate spaces there are. "strdel" works by copying the rest of the string over the deleted part, which means it has to copy all the rest of the string every time there is a duplicated space. This makes its worst-case something like O(n^2).