Google interview question

String operation and bit manipulation problem.