LeetCode刷题笔录Binary Tree Level Order Traversal II

从PCIe 3.0到6.0:为什么“阻抗一致性”比“绝对值”更重要?聊聊连接器与板材的选型影响 本文探讨了PCIe从3.0到6.0演进过程中,阻抗一致性相比绝对值的重要性,分析了连接器与板材选型对高速信号完整性的影响。随着速率提升至64GT/s,系统级阻抗控制和验证成为关键,文章提供了选型指南、验证方法论及工程实践建议,帮助工程师应对高速设计挑战。 阅读详情

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3
   / \
  9  20
    /  \
   15   7

return its bottom-up level order traversal as:

[
  [15,7],
  [9,20],
  [3]
]

看起来好像和一般的level order traversal没什么区别,就是把结果倒过来就行了。这里用了一个ArrayList<Integer> previousLevel来记录前一层的Node们。

public class Solution {
    public List<List<Integer>> levelOrderBottom(TreeNode root) {
        //the helper array that stores all the nodes of the previous level
        ArrayList<TreeNode> previousLevel;
        LinkedList<List<Integer>> result = new LinkedList<List<Integer>>();
        if(root == null){
            return result;
        }
        else{
            previousLevel = new ArrayList<TreeNode>();
            previousLevel.add(root);
        }
        while(!previousLevel.isEmpty()){
            LinkedList<Integer> thisLevel = new LinkedList<Integer>();
            ArrayList<TreeNode> temp = new ArrayList<TreeNode>();
            for(TreeNode node : previousLevel){
                thisLevel.add(node.val);
                if(node.left != null)
                    temp.add(node.left);
                if(node.right != null)
                    temp.add(node.right);
            }
            previousLevel = temp;
            result.addFirst(thisLevel);
            
        }
        return result;
    }
}


RAP Draft Handling 全面拆解:从独占 Draft 到协作 Draft 的架构与落地实践 独占 Draft 的启用点在行为定义头部的with draft。with draft;create;update;delete;with draft;上面这段代码来自一个完整的 Draft 启用示例,包含了 Draft 表声明、锁策略、ETag、Draft 动作等关键要素。:告诉框架草稿存哪。:告诉框架如何做并发控制与一致性保护。:把草稿生命周期动作显式暴露出来,让 UI 与事务引擎能正确驱动流程。 阅读详情

相关推荐

BOM 数据模型设计

字段名数据类型必填说明物料编码 (Part Number)字符串是唯一标识,主键。建议包含分类前缀(如STD-GEN-CUS-物料名称 (Part Name)字符串是版本 (Revision)字符串是如AB1.0,与编码组合构成唯一实例。状态 (Status)枚举是设计中(Draft)已发布(Released)已归档(Archived)已作废(Obsoleted)类型 (Type)枚举是专用件(Custom)借用件(Borrowed)通用件(Generic)标准件(Standard)

Davina_yu的博客 1756

LeetCode刷题笔录 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

likecool21的专栏 1万+

FreeRTOS任务调度实战:如何让STM32同时处理温湿度采集、OLED显示和云端通信

本文通过一个基于STM32的物联网终端项目,详细讲解了如何利用FreeRTOS实现多任务调度,同时处理温湿度采集、OLED显示和云端通信。文章深入探讨了任务规划、堆栈分配、信号量与消息队列等核心机制,并重点优化了ESP8266通信任务的非阻塞设计与稳定性,为构建响应迅速、运行可靠的嵌入式系统提供了实战指南。

weixin_29188043的博客 331

LeetCode刷题笔录 Two Sum

Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the

likecool21的专栏 1万+

SAP SD POD 配置与 VLPOD 操作:3步解决发货10件开票7件的业务场景

本文详细解析了SAP SD POD功能在解决发货与开票数量差异中的应用,通过3步配置法实现精准匹配。重点介绍了POD核心逻辑、关键配置步骤及VLPOD操作技巧,帮助企业高效处理易损品运输等复杂场景,提升供应链管理效率。

weixin_30613343的博客 393

不懂就学之挑战成为WorldQuant Brain顾问的第1天

WorldQuant Brain 是由 WorldQuant 公司开发的一个基于人工智能和机器学习的量化研究平台,旨在帮助量化研究员发现和构建有效的投资策略。WorldQuant 是一家全球领先的量化投资公司,专注于利用数据科学、技术和金融工程开发量化交易策略。

Yanbang1的博客 8384

LeetCode刷题笔录 Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key.Th

likecool21的专栏 6928

三分钟解决RKNN-Toolkit2安装失败:从模块报错到成功验证的完整记录

本文详细记录了RKNN-Toolkit2安装失败的解决方案,从环境配置到模型转换实战,特别针对常见的'No module named 'rknn''报错提供了完整修复指南。通过YOLOv8模型转换示例,展示了从ONNX到RKNN格式的完整流程,并分享了在RK3588芯片上的部署优化技巧。

html8的博客 264

Stanford Algorithms学习:Clustering 2

这是紧接上面的一道题,比较有趣 Question 2 In this question your task is again to run the clustering algorithm from lecture, but on a MUCH bigger graph. So big, in fact, that the distances (i.e., edge costs

likecool21的专栏 2567

抖音小程序开发 唤起收银台支付(可以选择支付宝APP支付或微信H5支付)

什么都别说,先看效果: 字节跳动也开放了小程序给商家接入,可以在旗下APP如抖音、今日头条、今日头条极速版等应用中即点即用,基于庞大的数亿用户量为其引流,帮助商家获取用户流量,销售商品,其模式和微信小程序差不多。 1、后台管理地址: https://developer.toutiao.com/ 2、开发文档地址: https://developer.toutiao.com/dev/cn/min...

悟空码字的博客 1万+

【点云概述】什么是点云、来源、种类、特点、处理?

【点云概述】什么是点云、来源、种类、特点、处理?点云(point cloud)是空间中点的数据集,可以表示三维形状或对象,通常由三维扫描仪获取。点云中每个点的位置都由一组笛卡尔坐标 ( X , Y , Z ) (X, Y, Z) (X,Y,Z)描述,有些可能含有色彩信息 ( R , G , B ) (R, G, B) (R,G,B)或物体反射面强度(Intensity)信。

智慧空间实验室 9813

Stanford Algorithms学习:Clustering

第二周的第一个编程作业,是利用贪婪算法来实现一个clustering的问题,和ML里学的unsupervised learning差不多。 Question 1 In this programming problem and the next you'll code up the clustering algorithm from lecture for computing a

likecool21的专栏 2507

单片机:实现FFT快速傅里叶变换算法(附完整源码)

单片机:实现FFT快速傅里叶变换算法(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 1099

LeetCode 刷题笔录 Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

likecool21的专栏 1806

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

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

LeetCode刷题笔录Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:

likecool21的专栏 1296

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

LeetCode刷题笔录Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

likecool21的专栏 1109

LeetCode刷题笔录 Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? 这题比较简单

likecool21的专栏 1043

LeetCode刷题笔录Unique Binary Search Trees

这里有个讲解(印度人口音真难懂)

likecool21的专栏 1043

LeetCode刷题笔录Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin

likecool21的专栏 1001

LeetCode刷题笔录 Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 随手写的一个,正常的读出每一位的数字然后反序: import java.lang.Math; public class Solution { public int revers

likecool21的专栏 941

LeetCode刷题笔录Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota

likecool21的专栏 878

LeetCode刷题笔录Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the f

likecool21的专栏 865

LeetCode刷题笔录Convert Sorted Array to Balanced Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这题可以kan'chu'lai

likecool21的专栏 855

求集合的交集/差集

先利用外部排序使两个磁盘文件有序,然后顺序读取两个文件,使用双指针求交集。在进阶 1 中,我们是通过双指针去做的,最坏情况下我们需要完整遍历。时,O(n log m) 可能明显优于 O(n + m)。的,这就使得我们可以通过从 1~1000 遍历来确定交集。,它们已经按非降序排序,请你返回两个数组的。和上一题的区别在于,这里需要找到重复的元素。返回一个数组,数组中的每个元素在。的每个字符串中都出现的共用字符(**注意:**列表中的整数可以按。较小,可以完整加载到内存,而。正整数组成的一个非空数组,按。

jyyyyx的算法之旅 112

LeetCode Hot 100 二叉树专题(二)3 题(Java)

本篇文章共 3 题:543. 二叉树的直径、102. 二叉树的层序遍历、108. 将有序数组转换为二叉搜索树。 每道题都统一按「① 题目分析 & 解题思路 → ② 常见解法(附代码)及讲解 → ③ 知识点总结」的顺序组织;代码使用 Java 编写,节点定义沿用 LeetCode 默认的 TreeNode。

2401_88612756的博客 365

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等)

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等) 题目描述: 给定三个字符串 s1、s2、s3,请你帮忙验证 s3 是否是由 s1 和 s2 交错 组成的。 两个字符串 s 和 t 交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空 子字符串: - s = s1 + s2 + ... + sn - t = t1 + t2 + ... + tm - |n - m| <= 1 - 交错 是 s1 + t

huayimenghan的博客 205

LeetCode 每日一题 2026/11/2-2026/11/8

记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步

AlphaTao的博客 175
上一篇: LeetCode刷题笔录Unique Paths
下一篇: LeetCode刷题笔录Minimum Path Sum
likecool21
博客等级 码龄14年 14粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值