Gokiwi Tech interview question

one regarding bit manipulation and other one was from dynamic programing