当前位置:网站首页>Preorder traversal of binary tree
Preorder traversal of binary tree
2022-07-19 06:26:00 【Patrick star`】
144. Preorder traversal of two tree - Power button (LeetCode)
subject :
Give you the root node of the binary tree root , Of its node value Before the order Traverse .
Ideas :
If you have a hand
Code :
void _preorderTraversal(struct TreeNode* root,int* arr,int* pi)
{
if(root == NULL)
{
return;
}
arr[(*pi)++] = root->val;
_preorderTraversal(root->left,arr,pi);
_preorderTraversal(root->right,arr,pi);
}
int* preorderTraversal(struct TreeNode* root, int* returnSize)
{
int* arr = (int*)malloc(sizeof(int)*100);
int len = 0;
_preorderTraversal(root,arr,&len);
*returnSize = len;
return arr;
}边栏推荐
- 【牛客】二叉树遍历
- In Chapter 5, can we directly call the run () method to start a new thread
- Solve cannot read properties of null (reading 'pickalgorithm')
- c语言 指定日期开始多少天 显示
- Volatile function of embedded C language
- js变量提升
- Bottom up and top-down attention: different processes and overlapping nervous systems 2014sci
- Qt Creator闪退解决办法
- Cours de mathématiques de base 2 Fonction Euler, écran linéaire, élargissement de l'Europe
- 【力扣】设计循环队列
猜你喜欢

Introduction to Darwin streaming server

Solve cannot read properties of null (reading 'pickalgorithm')

[antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique.....

【力扣】用栈实现队列

EOG based eye movement detection and gaze estimation for an asynchronous virtual keyboard

2022/07/14 learning notes (day07) array
![MySQL workbench basically uses [create a data table]](/img/cf/00818451ef0e8bcd5cc1d12f00d27c.png)
MySQL workbench basically uses [create a data table]

【力扣】用队列实现栈

Qt Creator闪退解决办法
![[force buckle] ring list II](/img/12/9cbc7081e2f7a87e77faf0e02a8c26.png)
[force buckle] ring list II
随机推荐
[force buckle] ring list II
Common serial communication UART seen from pictures
2022 robocom world robot developer competition - undergraduate group (provincial competition)
Acwing第 59 场周赛(AK)
【力扣】另一棵树的子树
Solve cannot read properties of null (reading 'pickalgorithm')
Antd is not defined
LeetCode字符串
Longest bracket match (linear DP)
EOG based eye movement detection and gaze estimation for an asynchronous virtual keyboard
有依赖的背包,狭义(二进制枚举),广义(树形dp)
Creation and implementation of WebService interface
Ehab the Xorcist (异或性质,构造)
2021 - 09 - 15
用头部运动学习无姿态注视偏差
Acwing game 57 (AK)
ES聚合分析报错:“reason“ : “Text fields are not optimised for operations
Basic mathematics course 2_ Euler function, linear sieve, extended Euler
Solutions to slow transmission speed of FileZilla virtual machine
Open source online markdown editor -- [editor.md]