ByteDance Interview Question

Graph problem similar to leetcode