当前位置:网站首页>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;
}
边栏推荐
- Vscode instant English translation plug-in [translation (English Chinese Dictionary)]
- What's the worst programmer you've ever seen?
- 2021 - 09 - 15
- Acwing game 59 (AK)
- XOR gun (bit operation, thinking, interval violence)
- 【力扣】另一棵树的子树
- 三角形牧场 (0/1背包)
- QT creator flashback solution
- Where have all the older programmers gone?
- DSL实现Bucket聚合
猜你喜欢
Eye tracking in virtual reality
Open source online markdown editor -- [editor.md]
通过VOR深度估计解决三维注视交互中的目标模糊问题
自下而上和自上而下的注意力:不同的过程和重叠的神经系统 2014sci
[force buckle] ring list II
解决:无法加载文件 C:\Program Files\.. 因为在此系统上禁止运行脚本...
2022/07/12 学习笔记 (day05)循环
Simple chrome script automatically skips the charging acknowledgment page after the video playback of station B ends
Using VOR depth estimation to solve the problem of target ambiguity in three-dimensional gaze interaction
[antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique.....
随机推荐
Typescript learning
Bottom up and top-down attention: different processes and overlapping nervous systems 2014sci
量子三体问题: 数值计算概述
串口循环缓存区 简单 免初始化 不用堆、指针、分段memcpy
Qtss constant
基于运动和视觉突出性的自我视频中的注意预测
Vscode instant English translation plug-in [translation (English Chinese Dictionary)]
Configure the 'log' shortcut key in vscode and remove the console log(‘‘); Semicolon in;
[bjoi2019] platoon formation (Group backpack)
三维凝视估计,没有明确的个人校准2018
【力扣】相同的树
【力扣】二叉树的前序遍历
Addition and subtraction of busybox date time
自下而上和自上而下的注意力:不同的过程和重叠的神经系统 2014sci
[force buckle] copy the linked list with random pointer
用头部运动学习无姿态注视偏差
In Chapter 5, can we directly call the run () method to start a new thread
[antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique.....
Baby Ehab Partitions Again(dp,构造,位运算)
Triangle ranch (0/1 backpack)