일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 매트랩
- Deep learning
- 캐나다 영주권
- C++
- 기본
- machine learning
- LV1
- 개발자
- 선형대수
- 코딩테스트
- leetcode
- LAA
- 머신러닝
- 알고리즘
- 컴퓨터과학과
- MATLAB
- 조지아텍
- 위니펙
- mpnp
- 주정부이민
- 방통대
- 온라인석사
- 프로그래머스
- Plotting
- EOI
- 방송통신대학교
- 딥러닝
- omscs
- cpp
- zeros
Archives
- Today
- Total
Byte by Byte
589. N-ary Tree Preorder Traversal.cpp 본문

/*
// Definition for a Node.
class Node {
public:
int val;
vector<Node*> children;
Node() {}
Node(int _val) {
val = _val;
}
Node(int _val, vector<Node*> _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public:
vector<int>v;
void pre(Node* root){
if(!root)return;
v.emplace_back(root->val);
for(int i=0; i<root->children.size();i++){
pre(root->children[i]);
}
}
vector<int> preorder(Node* root) {
pre(root);
return v;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
1748. Sum of Unique Elements.cpp (0) | 2021.10.08 |
---|---|
961. N-Repeated Element in Size 2N Array.cpp (0) | 2021.10.08 |
590. N-ary Tree Postorder Traversal.cpp (0) | 2021.10.08 |
1261. Find Elements in a Contaminated Binary Tree.cpp (0) | 2021.10.08 |
1347. Minimum Number of Steps to Make Two Strings Anagram.cpp (0) | 2021.10.08 |