leetcode 1161. Maximum Level Sum of a Binary Tree(二叉树最大层和)

【ue4】【新手入门】|静态网格模型碰撞设置和合并Actor(合并静态网格体) 上一期学到把构建好的房子模型变成一个静态网格体(也是一个模型)但是静态网格体是没有碰撞的 所以要给这个模型设置碰撞。 阅读详情

在这里插入图片描述

root所在层为1,后面依次加1.
每层求和,找到和最大的层数。

思路:

一层一层求和,想到BFS。
记录下最初的和为root.val.
后面的和超过这个值,就更新sum, 更新层数。

public int maxLevelSum(TreeNode root) {
    int level = 0;
    int maxLevel = 1;
    int sum = root.val;
    Queue<TreeNode> queue = new LinkedList<>();
    queue.offer(root);

    while(queue.size() > 0) {
        int size = queue.size();
        int tmp = 0;
        level ++;
        for(int i = 0; i < size; i++){
            TreeNode cur = queue.poll();
            tmp += cur.val;
            if(cur.left != null) queue.offer(cur.left);
            if(cur.right != null) queue.offer(cur.right);
        }
        
        if(tmp > sum) {
            sum = tmp;
            maxLevel = level;
        }
    }
    return maxLevel;
}
从工具选型到落地实践:吃透 SAP Fiori Launchpad 配置工具体系 摘要: SAP Fiori Launchpad配置远非简单添加应用和分配角色,涉及技术目录、业务目录、Spaces/Pages等多层管理。官方推荐新工具分工:技术目录用FLPAM维护应用定义,业务目录用FLPCM编排应用组合,Spaces/Pages优化用户体验布局,而传统Groups模式已被标记弃用。这种分层治理模式(定义层-编排层-展示层)能有效解决传输混乱、升级兼容性问题,尤其适合大规模项目实施。关键在于区分技术配置与业务呈现,避免将所有功能堆砌在单一旧工具中。(149字) 阅读详情

相关推荐

STM32与小米CyberGear微电机的CAN通信协议深度解析

本文深度解析STM32与小米CyberGear微电机的CAN通信协议,涵盖硬件连接、CAN总线配置、通信协议解析及多电机协同控制。重点介绍了基于STM32的电机控制实践,包括运动模式、速度与位置模式设置,以及数据反馈与故障诊断,为机器人及自动化设备开发提供实用指南。

www00的博客 371

leetcode 1161. Maximum Level Sum of a Binary Tree 最大层内元素和-耗时100

Problem:耗时100%,累加每一层的和,求出最大高度,得到最大值和对应的层数。

邹九的个人博客 56

LeetCode-1161. Maximum Level Sum of a Binary Tree

LeetCode-1161. Maximum Level Sum of a Binary Tree 原题链接:https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ 解题思路 其实就是二叉树的层次遍历的变种而已,二叉树层次遍历应该都很熟悉了,就不多说了 算法描述 Step1:如果根节点root为空,返回0 Ste...

ke1950523491的博客 264

告别模糊与偏色:使用RKISP Tuner为RK3588s+IMX415进行图像质量调优的实战心得

本文详细介绍了如何使用RKISP Tuner为RK3588s+IMX415进行图像质量调优的实战经验。从调试环境搭建到3A算法优化,再到画质增强模块的深度调参,提供了全面的技术指导和参数建议,帮助工程师解决噪声、色偏和细节模糊等常见问题,显著提升成像质量。

weixin_28729205的博客 460

Omnibox 2.11 NAS部署指南:家庭影音中枢的轻量化落地实践

家庭影音平台本质是本地化内容调度中枢,其核心在于聚合NAS媒体库、统一管理直播/IPTV/音频/视频等多源内容,并通过智能元数据匹配与硬解加速实现零门槛播放体验。技术原理上依赖Java轻量Web容器(Jetty)、SQLite嵌入式数据库双缓存架构,以及宿主机FFmpeg动态链接与HTTP/2直播代理治理能力。该方案显著降低4K播放卡顿、EPG加载失败、海报缺失等高频问题,适用于群晖、飞牛、绿联等主流NAS设备,尤其适配ARM64芯片与Realtek网卡等国产硬件生态。本文聚焦Omnibox 2.11在真实

weixin_30846347的博客 479

【LeetCode】1161. Maximum Level Sum of a Binary Tree 解题报告 (C++)

作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录题目描述题目大意解题方法BFS日期 题目地址:https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ 题目描述 Given the root of a binary tree, the l...

负雪明烛 1147

香橙派OPi 6系列选型指南:RK3588与RK3588S开发板深度对比

开发板选型是嵌入式系统设计的关键环节,尤其在边缘计算和AI推理等场景中,芯片的差异直接影响硬件架构。瑞芯微RK3588及其精简版RK3588S是当前高端开发板的核心方案,两者在PCIe通道、显示输出和SATA支持上存在显著区别。理解这些原理,有助于工程师根据项目需求快速匹配产品。香橙派OPi 6系列基于这两款芯片,衍生出OPi 6、OPi 6 Pro与OPi 6 Max三种形态:紧凑型适合嵌入式门禁与AI盒子,Pro版凭借双屏异显和PCIe 3.0满足收银机与视频分析,Max的双2.5G网口和大内存则面向轻

weixin_29185167的博客 236

Leetcode 1161.最大层内元素和(Maximum Level Sum of a Binary Tree)

Leetcode 1161.最大层内元素和 1 题目描述(Leetcode题目链接)   给你一个二叉树的根节点 root。设根节点位于二叉树的第 1 层,而根节点的子节点位于第 2 层,依此类推。   请你找出层内元素之和 最大 的那几层(可能只有一层)的层号,并返回其中 最小 的那个。 输入:[1,7,0,7,-8,null,null] 输出:2 解释: 第 1 层各元素之和为 1, 第 2...

qq_39378221的博客 196

【S32K3 MCAL配置】-3.4-CANFD配置-接收特定的“经典CAN/CANFD标准帧”和“经典CAN/CANFD扩展帧”(基于MCAL+FreeRTOS)

【S32K3 MCAL配置】-3.4-CANFD配置-接收特定的“经典CAN/CANFD标准帧”和“经典CAN/CANFD扩展帧”(基于MCAL+FreeRTOS)

「汽车电子助手」的博客 703

2026 拉勾网:JA4+指纹绕过 + sign逆向 + 动态城市参数,月采集10万+数据实战

2026年拉勾网反爬技术全面升级,采用JA4+ TLS指纹识别、动态sign签名等多维度防护体系。本文提供工业级爬虫解决方案,通过curl_cffi模拟浏览器指纹、逆向sign加密算法、动态生成城市参数三大核心技术,实现高效稳定的数据采集。系统采用分层架构设计,包含任务调度、签名生成、多线程引擎等模块,单月可获取10万+条招聘数据。重点解析了JA4+指纹识别原理、传统方法的局限性,以及通过HMAC-SHA256算法逆向sign参数的完整过程。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2398

LeetCode //C - 1161. Maximum Level Sum of a Binary Tree

【代码】LeetCode //C - 1161. Maximum Level Sum of a Binary Tree。

Made in Code 1075

数字 IC 笔试面试必考点(1)FPGA 芯片架构

FPGA 芯片架构是非常重要的,如果你不了解 FPGA 芯片内部的详细架构,那么...

新芯设计的博客 2825

1161. Maximum Level Sum of a Binary Tree**

1161. Maximum Level Sum of a Binary Tree** https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ 题目描述 Given the root of a binary tree, the level of its root is 1, the level of its children...

珍妮的选择的博客 384

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

1161. Maximum Level Sum of a Binary Tree

import java.util.* import kotlin.collections.HashMap /** * 1161. Maximum Level Sum of a Binary Tree * https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/description/ * *...

weixin_30664615的博客 247

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

[leetcode] 1161. Maximum Level Sum of a Binary Tree

Description Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level X is maximal. Example 1: Input: root = [1,7,0,7,-8,null,nu

Learning from the mistakes 245

1161 Maximum Level Sum of a Binary Tree

1 题目 Given therootof a binary tree, the level of its root is1,the level of its children is2,and so on. Return thesmallestlevelXsuch that the sum of all the values of nodes at levelXisma...

weixin_39145266的博客 224

Leetcode 1161. Maximum Level Sum of a Binary Tree

题目链接:2. Add Two Numbers 题目大意:给你由两个链表组成得数,链表上得每个位置得值代表一个位得值,例如3->8->4就代表483这个值,然后两个链表相加,返回结果。 题目思路:简单题,每次相加得时候记录一次进位就可以了,只不过处理链表得时候比较麻烦,具体看代码吧 时间复杂度&&空间复杂度:O(max(n,m))&&O(n+m)(n,m...

Nemaleswang的博客 266

LeetCode解题分享:1161. Maximum Level Sum of a Binary Tree

Problem Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level X is m...

DaVinciL的博客 605

LeetCode C++ 1161. Maximum Level Sum of a Binary Tree【Tree/BFS】中等

Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level X is maximal. Example 1: Input: root = [1,7,0,7,-8,null,nul

memcpy0的博客 396

LeetCode 1161. Maximum Level Sum of a Binary Tree (Medium)

Description: Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level ...

weixin_45744426的博客 312

LeetCode #1161 Maximum Level Sum of a Binary Tree 最大层内元素和

输入:root = [989,null,10250,98693,-89388,null,null,null,-32127]设根节点位于二叉树的第 1 层,而根节点的子节点位于第 2 层,依此类推。请返回层内元素之和 最大 的那几层(可能只有一层)的层号,并返回其中 最小 的那个。输入:root = [1,7,0,7,-8,null,null]所以我们返回第 2 层的层号,它的层内元素之和最大。第 3 层各元素之和为 7 + -8 = -1,记录每一层的和及对应层数输出最大的和的层的编号。

NSJ85的博客 164

【Leetcode】1161. Maximum Level Sum of a Binary Tree

题目地址: https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ 给定一个二叉树,问其哪一层的节点数字和最大。若有多个解,则返回最小的那个。树根的层数规定为111。 直接用层序遍历即可。代码如下: import java.util.LinkedList; import java.util.Queue; public class Solution { public int maxLevelSum(TreeNode root

数学、算法爱好者的博客 254

leetcode - 1161. Maximum Level Sum of a Binary Tree

leetcode - 1161

sinat_41679123的博客 1082

LeetCode - Medium - 1161. Maximum Level Sum of a Binary Tree

Topic Tree Breadth-First Search Description https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that th

KISS 252

LeetCode1161. Maximum Level Sum of a Binary Tree

【代码】LeetCode1161. Maximum Level Sum of a Binary Tree。

叶卡捷琳堡的博客 207
上一篇: leetcode 2352. Equal Row and Column Pairs(相等的行和列)
下一篇: torchvision.ops.nms实现NMS
蓝羽飞鸟
博客等级 码龄8年 1万+粉丝 727原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝羽飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址