当前位置:网站首页>606. 根据二叉树创建字符串(视频讲解!!!)
606. 根据二叉树创建字符串(视频讲解!!!)
2022-07-30 09:15:00 【学习追求高效率】
13. (有视频)前序遍历二叉树 转成 字符串
前序遍历二叉树转成字符串
public String tree2str(TreeNode root) {
StringBuilder sb = new StringBuilder();
tree2strChild(root,sb);
return sb.toString();
}
private void tree2strChild(TreeNode t,StringBuilder sb) {
if(t == null) return ;
sb.append(t.val);
if(t.left != null) {
sb.append("(");
tree2strChild(t.left,sb);
sb.append(")");
}else {
if(t.right == null) {
return;
}else{
sb.append("()");
}
}
if(t.right == null) {
return;
}else{
sb.append("(");
tree2strChild(t.right,sb);
sb.append(")");
}
}
边栏推荐
猜你喜欢

涛思 TDengine 2.6+优化参数

PyQt5-用像素点绘制正弦曲线

HCIP - MPLS VPN experiment

仿牛客网项目第二章:开发社区登录模块(详细步骤和思路)

Integral Topic Notes - Path Independent Conditions

Kotlin value class - value class

详解JVM垃圾回收

How to run dist file on local computer

Version management of public Jar packages

An article to understand service governance in distributed development
随机推荐
积分专题笔记-与路径无关条件
leetcode 剑指 Offer 15. 二进制中1的个数
leetcode 剑指 Offer 58 - I. 翻转单词顺序
嘉为鲸翼·多云管理平台荣获信通院可信云技术服务最佳实践
Network/Information Security Top Journal and Related Journals Conference
PyQt5快速开发与实战 7.4 事件处理机制入门 and 7.5 窗口数据传递
iperf3 参数选项详细说明
实施敏捷过程中这些常见的问题你可曾遇到?
The R installation package has error in rawtochar(block[seq_len(ns)]) :
(***重点***)Flink常见内存问题及调优指南(一)
快解析结合泛微OA
统一异常处理导致ResponseBodyAdvice失效
积分专题笔记-积分的定义
Use the R language to read the csv file into a data frame, and then view the properties of each column.
342 · Valley Sequence
The use of qsort function and its analog implementation
转行软件测试,报培训班3个月出来就是高薪工作,靠谱吗?
虚幻引擎图文笔记:could not be compiled. Try rebuilding from source manually.问题的解决
els 方块向左移动
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers