//
// 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;
}
