题目:翻转二叉树


方法①:深度优先遍历(链接)

/**
* Definition for a binary tree node.
* struct TreeNode {
*     int val;
*     TreeNode *left;
*     TreeNode *right;
*     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:TreeNode * invertTree(TreeNode* root){if (!root)return root;DFS(root, root->left, root->right);return root;}void DFS(TreeNode *root, TreeNode *p1, TreeNode *p2){if (!p1 && !p2)return;TreeNode *s = root->left;root->left = root->right;root->right = s;if (p1)DFS(p1, p1->left, p1->right);if (p2)DFS(p2, p2->left, p2->right);}
};

Leetcode | 513. Find Bottom Left Tree Value相关推荐

  1. LeetCode 513. Find Bottom Left Tree Value

    513. Find Bottom Left Tree Value Given a binary tree, find the leftmost value in the last row of the ...

  2. [LeetCode] 513. Find Bottom Left Tree Value_ Medium tag: BFS

    Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input:2/ \1 3Ou ...

  3. 513. Find Bottom Left Tree Value

    Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input:2/ \1 3Ou ...

  4. 【LeetCode】513. Find Bottom Left Tree Value

    问题描述 问题链接:https://leetcode.com/problems/find-bottom-left-tree-value/#/description Given a binary tre ...

  5. Java描述 LeetCode,513. Find Bottom Left Tree Value 找左下角的值

    大家好,我是河海哥,专注于后端,如果可以的话,想做一名code designer而不是普通的coder,一起见证河海哥的成长,您的评论与赞是我的最大动力,如有错误还请不吝赐教,万分感谢.一起支持原创吧 ...

  6. leetcode讲解--513. Find Bottom Left Tree Value

    题目 Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input:2/ \1 ...

  7. 【Breadth-first Search 】513. Find Bottom Left Tree Value

    输入:一颗二叉树 输出:这颗树的最下面一层最左边的节点值. 分析: 用BFS的思路解决最直观.读每一层,在每一层记录第一个元素的值.在队列中第一层:1:第二层:2,3:第三层 4,5,6.如此继续下去 ...

  8. LeetCode 545. Boundary of Binary Tree 二叉树边界

    LeetCode 545. Boundary of Binary Tree 二叉树边界 Given a binary tree, return the values of its boundary i ...

  9. LeetCode:Minimum Depth of Binary Tree,Maximum Depth of Binary Tree

    LeetCode:Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth ...

最新文章

  1. 喵哈哈村的魔法考试 Round #1 (Div.2) 题解源码(A.水+暴力,B.dp+栈)
  2. python 视频剪裁,剪切,合并
  3. SAP WM 显示TR ITEM的标准报表LX09
  4. 查找 之 散列表查找(哈希表)
  5. 抢救站位图片_抢救配合流程和站位,你真的规范了吗
  6. MySQL自定义函数(CREATE FUNCTION)
  7. Python图像处理工具——PIL、opencv、matplotlib
  8. javascript学习系列(9):原数组发生变化的情况
  9. 计算机多媒体专业是什么专业,什么是计算机多媒体技术
  10. 原生JS 将canvas生成图片
  11. GWR4 软件输入数据制作
  12. iptv鉴权 php,[转]关于openwrt用于dhcp客户端协议突破iptv的dhcp+鉴权(ipoe)
  13. 前台、中台、后台到底是什么?
  14. EXFAT文件系统DBR的完美恢复
  15. excel shared formula处理
  16. IPC技术与评分卡技术区别
  17. storyboard 苹果启动图_iOS13 启动图适配
  18. 模型选择——子集选择法(Subset Selection)
  19. Visual SourceSafe 2005(VSS2005)与Visual Studio 2005的开发环境搭建
  20. 工具系列————教育邮箱激活Clion

热门文章

  1. 单元测试中Assert类的用法
  2. EF Code First 简单的示例
  3. html 拼接onmouseout,HTML onmouseout事件用法及代码示例
  4. mysql文件软连接失败,解决打包软链接打包失败问题
  5. ntp如何确认与服务器偏差_LED电子时钟显示屏如何实现时间同步统一校时?
  6. java 自定义报表_灵活数据分析 | 自定义数据分析_集力数据系统平台_Java报表系统软件...
  7. python与材料计算公式_《从问题到程序:用Python学编程和计算》——2.11 补充材料-阿里云开发者社区...
  8. flash php socket通信_php socket通信机制实例说明
  9. 中tr不能显示字符_垃圾文本识别中基本操作指南和错误总结,第三部分
  10. 登录id 黑苹果_黑苹果MacOSCatalina无法登录AppStore修复