1、题目描述

2、问题分析

使用层序遍历思想

3、代码

 int findBottomLeftValue(TreeNode* root) {
if (root == NULL)
return ;
queue<TreeNode*> q;
q.push(root); int val = ;
while (!q.empty()) {
int size = q.size();
for(int i = ; i < size; i++) {
TreeNode *node = q.front();
if (node->left != NULL)
q.push(node->left);
if (node->right != NULL)
q.push(node->right); if (i == )
val = node->val;
q.pop();
}
}
return val;
}

LeetCode题解之Find Bottom Left Tree Value的更多相关文章

  1. leetcode算法: Find Bottom Left Tree Value

    leetcode算法: Find Bottom Left Tree ValueGiven a binary tree, find the leftmost value in the last row ...

  2. LeetCode题解:(114) Flatten Binary Tree to Linked List

    题目说明 Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 ...

  3. [LeetCode 题解]: Maximum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  4. 【LeetCode】513. Find Bottom Left Tree Value 解题报告(Python & C++ & Java)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BFS DFS Date 题目地址:https:// ...

  5. [LeetCode 题解]: Minimum Depth of Binary Tree

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...

  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. LeetCode题解之 Subtree of Another Tree

    1.题目描述 2.问题分析 判断一个节点,然后判断子树. 3.代码 bool isSubtree(TreeNode* s, TreeNode* t) { if (s == NULL) return f ...

  8. LeetCode题解之Diameter of Binary Tree

    1.题目描述 2.分析 深度优先. 3.代码 int ans; int diameterOfBinaryTree(TreeNode* root) { ans = ; depth(root); ; } ...

  9. LeetCode题解之 Increasing Order Search Tree

    1.题目描述 2/问题分析 利用中序遍历,然后重新构造树. 3.代码 TreeNode* increasingBST(TreeNode* root) { if (root == NULL) retur ...

随机推荐

  1. solr7.3.1在CentOS7上的安装

    1 solr的下载 从Solr官方网站(http://archive.apache.org/dist/lucene/solr/7.3.1/ )下载Solr最新版本, 根据Solr的运行环境,Linux ...

  2. Chapter 4 Invitations——1

    In my dream it was very dark, and what dim light there was seemed to be radiating from Edward's skin ...

  3. Netty实现简单HTTP代理服务器

    自上次使用Openresty+Lua+Nginx的来加速自己的网站,用上了比较时髦的技术,感觉算是让自己的网站响应速度达到极限了,直到看到了Netty,公司就是打算用Netty来替代Openresty ...

  4. AspectJ在Spring中的使用

    在上一篇AspectJ的入门中,简单的介绍了下AspectJ的使用,主要是以AspectJ的example作为例子.介绍完后也留下了几个问题:1)我们在spring中并没有看到需要aspectj之类的 ...

  5. Zookeeper Client简介

    直接使用zk的api实现业务功能比较繁琐.因为要处理session loss,session expire等异常,在发生这些异常后进行重连.又因为ZK的watcher是一次性的,如果要基于wather ...

  6. 基本排序算法Golang

    摘要 排序有内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存. 冒泡排序 func BubbleSort(ve ...

  7. Python机器学习笔记:常用评估指标的用法

    在机器学习中,性能指标(Metrics)是衡量一个模型好坏的关键,通过衡量模型输出y_predict和y_true之间的某种“距离”得出的. 对学习器的泛化性能进行评估,不仅需要有效可行的试验估计方法 ...

  8. Java反射,注解,以及动态代理

    Java反射,注解,以及动态代理 基础  最近在准备实习面试,被学长问到了Java反射,注解和动态代理的内容,发现有点自己有点懵,这几天查了很多资料,就来说下自己的理解吧[如有错误,望指正] Java ...

  9. Revit二次开发: 文件损坏

    哪些因素可能会导致损坏? 损坏的原因也各不相同,包括但不限于 无法读取/写入存储介质 程序发生崩溃(特别是在数据写入 RVT 模型时) 附加模块以通过正常 UI 无法或意外的方式修改图元 未经测试的多 ...

  10. WPF 列表虚拟化时的滚动方式

    ListBox的滚动方式 分为像素滚动和列表项滚动 通过ListBox的附加属性ScrollViewer.CanContentScroll来设置.因此ListBox的默认模板中,含有ScrollVie ...