文章
25
粉丝
137
获赞
7
访问
130.2k
#include<iostream>
using namespace std;
typedef struct node {
char val;
struct node* left, * right;
}*TreeNode;
void back(TreeNode &root, string pre, string mid, int f1, int l1, int f2, int l2) {
if (l1 < f1 || l2 < f2)
return;
if (root == NULL) {
root = (TreeNode)malloc(sizeof(struct node));
root->val = pre[f1];
root->left = NULL;
root->right = NULL;
}
int pos = mid.find(pre[f1]);
back(root->left, pre, mid, f1 + 1, f1 + pos - f2, f2, pos - 1);
back(root->right, pre, mid, f1 + pos - f2 + 1, l1, pos + 1, l2);
}
void Late(TreeNode root) {
if (root == NULL)
&nbs...
登录后发布评论
暂无评论,来抢沙发