Superhuman interview question

Leet code hard, DP, Trees, Searching, Graphs.