TikTok Interview Question

about a graph algorithm and very hard