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 3
Output:
1
Example 2:
Input:
1
/ \
2 3
/ / \
4 5 6
/
7
Output:
7
题目含义:给定一个二叉树,求最底层的最左边的值
1 public int findBottomLeftValue(TreeNode root) {
2 Queue<TreeNode> q = new LinkedList<>();
3 q.add(root);
4 while (!q.isEmpty())
5 {
6 root = q.poll();
7 if (root.right !=null) q.offer(root.right);
8 if (root.left !=null) q.offer(root.left);
9 }
10 return root.val;
11 }
513. Find Bottom Left Tree Value的更多相关文章
- LN : leetcode 513 Find Bottom Left Tree Value
lc 513 Find Bottom Left Tree Value 513 Find Bottom Left Tree Value Given a binary tree, find the lef ...
- 513. Find Bottom Left Tree Value - LeetCode
Question 513. Find Bottom Left Tree Value Solution 题目大意: 给一个二叉树,求最底层,最左侧节点的值 思路: 按层遍历二叉树,每一层第一个被访问的节 ...
- [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 ...
- 513 Find Bottom Left Tree Value 找树左下角的值
给定一个二叉树,在树的最后一行找到最左边的值. 详见:https://leetcode.com/problems/find-bottom-left-tree-value/description/ C+ ...
- 【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 ...
- [LC] 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 ...
- 【LeetCode】513. Find Bottom Left Tree Value 解题报告(Python & C++ & Java)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 BFS DFS Date 题目地址:https:// ...
- LeetCode 513. 找树左下角的值(Find Bottom Left Tree Value)
513. 找树左下角的值 513. Find Bottom Left Tree Value 题目描述 给定一个二叉树,在树的最后一行找到最左边的值. LeetCode513. Find Bottom ...
- Leetcode之深度优先搜索(DFS)专题-513. 找树左下角的值(Find Bottom Left Tree Value)
Leetcode之深度优先搜索(DFS)专题-513. 找树左下角的值(Find Bottom Left Tree Value) 深度优先搜索的解题详细介绍,点击 给定一个二叉树,在树的最后一行找到最 ...
随机推荐
- JAVA获取指定日期的周一的日期
/** * 获取当前周的周一的日期 * @param date 传入当前日期 * @return */ public static Date getThisWeekMonday(Date date) ...
- 【LeetCode】1436. 旅行终点站 Destination City (Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 set 日期 题目地址:https://leetcod ...
- 【九度OJ】题目1467:二叉排序树 解题报告
[九度OJ]题目1467:二叉排序树 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1467 题目描述: 二叉排序树,也称为二叉查找树 ...
- 1007 - Mathematically Hard
1007 - Mathematically Hard PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 6 ...
- Centos/Docker/Nginx/Node/Jenkins 操作
Centos Centos 是一个基于 Linux 的开源免费操作系统 # 本地拷贝文件到远程服务器scp output.txt root@47.93.242.155:/data/ output.tx ...
- 【机器学习】Pandas库练习-获取yahoo金融苹果公司的股票数据
# 获取yahoo金融苹果公司的股票数据. # 1.分析拉取的数据,找到收盘数据列的列名. # 2.绘制收盘价格柱状图. # 3.分析拉取的数据涨跌率,股价移动平均和波动率. # 4. 找出开盘价和收 ...
- Chapter 14 G-estimation of Structural Nested Models
目录 14.1 The causal question revisited 14.2 Exchangeability revisited 14.3 Structural nested mean mod ...
- Java初学者作业——编写JAVA程序,根据用户输入课程名称,输出对应课程的简介,各门课程的简介见表
返回本章节 返回作业目录 需求说明: 编写JAVA程序,根据用户输入课程名称,输出对应课程的简介,各门课程的简介见表 课程名称 课程简介 JAVA课程 JAVA语言是目前最流行的编写语言,在本课程中将 ...
- SpringBoot集成Actuator端点配置
1.说明 Actuator端点可以监控应用程序并与之交互. Spring Boot包括许多内置的端点, 比如health端点提供基本的应用程序运行状况信息, 并允许添加自定义端点. 可以控制每个单独的 ...
- win10 安装vue 详解-包括node.js、npm、webpack
1.下载 去官网下载 node.js https://nodejs.org/en/download/ 一般不会选择最新的,我安装的是 12.18.4 进入历史记录页面网址 https://nodejs ...