일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- EOI
- MATLAB
- 주정부이민
- mpnp
- cpp
- leetcode
- 코딩테스트
- Deep learning
- 매트랩
- 머신러닝
- 조지아텍
- 온라인석사
- 마니토바
- C++
- 캐나다 영주권
- omscs
- 알고리즘
- LAA
- 방통대
- 컴퓨터과학과
- 방송통신대학교
- LV1
- 선형대수
- 프로그래머스
- Plotting
- zeros
- 개발자
- 기본
- machine learning
- 딥러닝
Archives
- Today
- Total
Krononberg
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 |