0
点赞
收藏
分享

微信扫一扫

【五:(mock数据)springboot+mock集成swaggerConfig】

年夜雪 2023-10-20 阅读 32

在这里插入图片描述

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */


/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int TreeSize(struct TreeNode* root)
{
    return root == NULL ? 0 : TreeSize(root->left) + TreeSize(root->right) + 1;
}
void Inorder(struct TreeNode* root,int* a,int* pi)
{
    if(root == NULL)
        return ;
    Inorder(root->left,a,pi);
    a[(*pi)++] = root->val;
    Inorder(root->right,a,pi);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize){
    *returnSize = TreeSize(root);
    int* a = (int*)malloc((*returnSize) * sizeof(int));
    int i=0;
    Inorder(root,a,&i);
    return a;
}
举报

相关推荐

0 条评论