Qualcomm interview question

Basic bit manipulation question, with a dynamic programming twist.