Pergunta de entrevista da empresa Imperva

The bit manipulation question was a bit tricky.