This commit is contained in:
2025-03-25 20:27:05 +08:00
parent cbd9bd31a9
commit a89bec24e9
3 changed files with 107 additions and 0 deletions

37
src/lcp_67.c Normal file
View File

@@ -0,0 +1,37 @@
//
// Created by xfj12 on 2025/3/25.
//
#include <solution/lcp_67.h>
#include <stdio.h>
#include <stdlib.h>
void inorder(struct TreeNode *root)
{
if (root == NULL)
return;
inorder(root->left);
if (root->left != NULL && root->val != -1)
{
struct TreeNode *p = root->left;
root->left = malloc(sizeof(struct TreeNode));
root->left->left = p;
root->left->right = NULL;
root->left->val = -1;
}
if (root->right != NULL && root->val != -1)
{
struct TreeNode *p = root->right;
root->right = malloc(sizeof(struct TreeNode));
root->right->right = p;
root->right->left = NULL;
root->right->val = -1;
}
inorder(root->right);
}
struct TreeNode *expandBinaryTree(struct TreeNode *root)
{
inorder(root);
return root;
}