当前位置:网站首页>2022.5.30-----leetcode.1022
2022.5.30-----leetcode.1022
2022-06-09 12:28:00 【路Lu727】
//模拟栈递归
int ans=0;
String s="";
public int sumRootToLeaf(TreeNode root) {
dfs(root);
return ans;
}
void dfs(TreeNode root){
s+=root.val;
if(root.left==null&&root.right==null)
ans+=Integer.parseInt(s,2);
if(root.left!=null){
dfs(root.left);
s=s.substring(0,s.length()-1);
}
if(root.right!=null){
dfs(root.right);
s=s.substring(0,s.length()-1);
}
}边栏推荐
- Wsl2 environment setup
- 树的直径(补充:另一种 DP)
- 如何做数据可视化分析
- [C language practice - Young's matrix]
- 云呐|固定资产归哪个部门管理,归谁管理
- Introduction to culture CNI topic 3: simple source code analysis of multi network CNI plug-ins
- 周博磊《模型可解释性年度进展概述》20200805
- 云呐|RFID资产管理,rfid资产管理系统优势
- 数字化转型的七个错误认知
- Wechat applet - user authorization to obtain information
猜你喜欢

Seven misconceptions of digital transformation

Yunna RFID asset management, advantages of RFID asset management system
![[leetcode weekly race record] record of the 79th biweekly race + the 295th weekly race](/img/ce/bf00add3a54f9efd0776dda522f31f.png)
[leetcode weekly race record] record of the 79th biweekly race + the 295th weekly race

Record the troubleshooting of high program memory consumption

How can PostgreSQL in k8s export query results and import them to the database on the local windows machine

Yunna | which department manages the fixed assets and who manages them

数据库的安装--mysql

使用nodejs导出md/Markdown文档当中的图片到本地并替换原始图片链接为本地图片链接

Explanation of the top command

Yunna intelligent operation and maintenance management system platform, visual operation and maintenance system management
随机推荐
ES6 basic grammar knowledge
云呐|资产管理系统有哪些类型,分为哪几方面
射频同轴连接器和电缆指南--【转自微信公众号射频课堂】
【C语言练习——打印菱形及其变形】
c语言--单循环链表
VMware ESXI software 英文版安装步骤
[C language practice - merging two ordered sequences]
面试题 08.04. 幂集
fastapi基于pytest的异步测试(tortoise-orm)
数据库day-1
Analysis on the resumption of the most serious downtime in the history of Facebook on October 4, 2021
炒作剽窃、内鬼欺诈 OpenSea上常见的NFT骗局及安全建议
[C language practice - Young's matrix]
JVM运行时内存区系列之方法区
网络攻击盯上民生领域,应对DDoS和APT攻击,如何有效防御?
Yunna | which department manages the fixed assets and who manages them
Notes - round square tree
How to solve the worry of enterprise network with the acceleration of cloud network integration on the third anniversary of 5g licensing?
com.alibaba.fastjson.JSONException: syntax error, pos 1, line 1, column 2测试
What are the characteristics of Bi reporting system