每日一题-LeetCode606根据二叉树创建字符串-递归-深搜-数据结构

原题链接
代码如下:
class Solution {
public:
string tree2str(TreeNode* root) {
if(root == NULL)
return "";
else if(root -> left == NULL && root -> right == NULL)
return to_string(root-> val);
else if(root -> left == NULL && root -> right != NULL)
return to_string(root -> val) + "()" + "(" + tree2str(root -> right) + ")";
else if(root -> left !=

每日一题-LeetCode606根据二叉树创建字符串-递归-深搜-数据结构最先出现在Python成神之路

版权声明:
作者:zhangchen
链接:https://www.techfm.club/p/26432.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>