Capgemini Engineering Interview Question

Bits and string manipulation based questions and asked to write a code for that.