AppsFlyer interview question

A heap question, and Dynamic Programming