摘要: 题目链接:https://leetcode-cn.com/problems/invert-binary-tree/ 题目描述: 方法一:层序遍历(BFS) 采用层序遍历的方式,每遍历一个节点,就将该节点的左右孩子交换。 /** * Definition for a binary tree node. 阅读全文
posted @ 2021-02-03 15:14 张宵 阅读(53) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/binary-tree-right-side-view/ 题目描述: 1.二叉树的右视图 思路:二叉树层序遍历的时候,判断是否遍历到单层的最后面的元素,如果是,就放进result数组中。 /** * Definition f 阅读全文
posted @ 2021-02-03 14:04 张宵 阅读(41) 评论(0) 推荐(0)