ByteDance interview question

Medium Leetcode using BFS and DFS