TikTok interview question

about a graph algorithm and very hard