UBS Interview Question

String manipulation and some bit problems.