Yea I don't understand what the parent comment wants to say. You need to have a lookup structure (even if its only a bit) and then you can do one pass over the string. The lookup or adding a character doesn't count as a pass. And there is no way to omit this anyway.