[leetCode刷题笔记]606. Construct String from Binary Tree
来源:互联网 发布:个人网站博客系统php 编辑:程序博客网 时间:2024/06/05 20:02
奇葩的规则,左子树的规则必须打。
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public String tree2str(TreeNode t) { if (t == null) return ""; StringBuilder sb = new StringBuilder(); sb.append(t.val); if (t.left != null || t.right != null) { sb.append("("); sb.append(tree2str(t.left)); sb.append(")"); } if (t.right != null) { sb.append("("); sb.append(tree2str(t.right)); sb.append(")"); } return sb.toString(); }}
阅读全文
0 0
- [leetCode刷题笔记]606. Construct String from Binary Tree
- [leetcode]606. Construct String from Binary Tree
- [leetcode]: 606. Construct String from Binary Tree
- [LeetCode] 606. Construct String from Binary Tree
- Leetcode 606. Construct String from Binary Tree
- LeetCode: 606. Construct String from Binary Tree
- [LeetCode]606. Construct String from Binary Tree
- leetcode 606. Construct String from Binary Tree
- LeetCode 606. Construct String from Binary Tree
- leetcode: 606. Construct String from Binary Tree
- Leetcode-606. Construct String from Binary Tree
- leetcode-606. Construct String from Binary Tree
- leetcode-606. Construct String from Binary Tree
- Leetcode-536. Construct Binary Tree from String
- LeetCode 606 Construct String from Binary Tree
- LeetCode 606 Construct String from Binary Tree
- LeetCode Construct String from Binary Tree
- leetcode 606 Construct String from Binary Tree
- 听说你精通TCP,来问你几个问题考考你是不是真的精通
- druid监控配置及sql注入防火墙配置
- 字符串哈希
- WEB服务器与应用服务器的区别
- arduino等开源平台
- [leetCode刷题笔记]606. Construct String from Binary Tree
- Eclipse Java注释模板设置详解
- stylus使用再升级
- cesium 3D tiles源码安装
- vert.x笔记:1.vert.x介绍
- PID 参数整定口诀
- AJAX
- vert.x笔记:2.hello vert.x--第一个vert.x hello world工程
- [YTU]_2919( Shape系列-5)