Open harrysimply opened 2 years ago
【简单】
向题目给定点四个方向做深度搜索,执行涂色任务;设立两个终止条件,当dfs数组坐标越界搜索终止;当搜索坐标与涂色颜色相同终止;当搜索坐标与指定坐标颜色不同时终止。
【中等】
用0和1表示的岛屿,扫描每一个点,找到值为1的点然后使用dfs搜索找到周边的点,dfs返回这个点所在岛屿的面积。同时dfs也将便利过的1值归0.
116. Populating Next Right Pointers in Each Node
将左侧树节点链表指针指向右侧树节点。
DFS