Domanda di colloquio di Qualcomm

Basic bit manipulation question, with a dynamic programming twist.