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

class Solution {
public:
int pivotIndex(vector<int>& nums) {
if(nums.size()<3) return -1;
int sum[nums.size()], max;
for(int i = 0; i < nums.size(); i ++){
i == 0?sum[i] = nums[i] : sum[i] = nums[i] + sum[i-1];
}
max = sum[nums.size()-1];
for(int i = 0; i < nums.size(); i++){
if(max - sum[i] == sum[i] - nums[i]){
return i;
}
}
return -1;
}
};

[LeetCode]Find Bottom Left Tree Value的更多相关文章

  1. [LeetCode] 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 ...

  2. LeetCode——Find Bottom Left Tree Value

    Question Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: ...

  3. leetcode算法: Find Bottom Left Tree Value

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

  4. Leetcode之深度优先搜索(DFS)专题-513. 找树左下角的值(Find Bottom Left Tree Value)

    Leetcode之深度优先搜索(DFS)专题-513. 找树左下角的值(Find Bottom Left Tree Value) 深度优先搜索的解题详细介绍,点击 给定一个二叉树,在树的最后一行找到最 ...

  5. LeetCode 513. 找树左下角的值(Find Bottom Left Tree Value)

    513. 找树左下角的值 513. Find Bottom Left Tree Value 题目描述 给定一个二叉树,在树的最后一行找到最左边的值. LeetCode513. Find Bottom ...

  6. 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 ...

  7. 513. Find Bottom Left Tree Value - LeetCode

    Question 513. Find Bottom Left Tree Value Solution 题目大意: 给一个二叉树,求最底层,最左侧节点的值 思路: 按层遍历二叉树,每一层第一个被访问的节 ...

  8. 【LEETCODE OJ】Binary Tree Postorder Traversal

    Problem Link: http://oj.leetcode.com/problems/binary-tree-postorder-traversal/ The post-order-traver ...

  9. 【LeetCode】199. Binary Tree Right Side View 解题报告(Python)

    [LeetCode]199. Binary Tree Right Side View 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/probl ...

随机推荐

  1. idea IDE 导入的项目没有显示目录结构

    解决方法:1.关闭 idea 2.删除该项目录下的 .idea 文件 3.重新 open 项目

  2. centos7修改静态ip地址

    今天逛园的时候突然发现这篇有关网络参数修改的文章写的很好,简单又使用,格式也很好的,所以就引用过来了. http://www.cnblogs.com/hongdada/p/6666932.html

  3. django入门-初窥门径-part1

    尊重作者的劳动,转载请注明作者及原文地址 http://www.cnblogs.com/txwsqk/p/6510917.html 完全翻译自官方文档 https://docs.djangoproje ...

  4. IECapt、CutyCapt 生成网页快照

    IECapt.CutyCapt  生成网页快照 http://iecapt.sourceforge.net/ http://cutycapt.sourceforge.net/ 1.以管理员身份 运行c ...

  5. 【转载】Java 9 新特性——模块化

    来自 <http://www.jianshu.com/p/053a5ca89bbb#> 前言 年,我们将迎来 Java 语言的 22 岁生日,22岁,对于一个人而言,正是开始大展鸿图的年纪 ...

  6. 除法保留小数bit位 + 四舍五入

    /*num1/num2 保留bit 位小数 , 四舍五入*/ #include<bits/stdc++.h> using namespace std; ]; int main() { in ...

  7. [转] ELK 之 Logstash

    [From] https://blog.csdn.net/iguyue/article/details/77006201 ELK 之 Logstash 简介: ELK 之 LogstashLogsta ...

  8. MySql互为主从配置文件及配置方法

    # Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 6 ...

  9. [Xamarin]測試帳號申請與到期後如何續用 (转帖)

    在Xamarin網站上可以申請30天試用的測試帳號.試用期內,Xamarin會提供完整的功能試用. 30天試用時間到期後,在Visual Studio裡面你載入你的專案的時候,專案旁會標註(無法使用) ...

  10. JavaScript设计模式-5.接口

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...