Imperva Interview Question

The bit manipulation question was a bit tricky.