Groupon interview question

Bit manipution & an algorithm question about string.