Superhuman interview question

complex leet code style questions (graph)