wonder whether there exists an algorithm that just scans the string once and only uses a constant number of extra cells besides the string.