Pregunta de entrevista de Broadcom

first question was a dp question, second was a sorting question and there was a bit manipulation bonus question