Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Graph Neural Network
- 선형대수
- 수치최적화
- 경로생성
- autonomous vehicle
- self driving car
- MDP
- 동적라이브러리
- 백준
- Motion Planning
- 정적라이브러리
- 공유라이브러리
- 소프티어
- CPP
- GNN
- path planning
- 강화학습
- solver
- GIT
- CUDA
- Hybrid A star
- C++
- Frenet Coordinate
- C
- PathPlanning
- DynamicProgramming
- Dubins Path
- Leetcode
- OSQP
- Recursion
Archives
- Today
- Total
Swimmer
[LeetCode] 2331. Evaluate Boolean Binary Tree, cpp 본문
Solution
- use recursive structure
Tag
- Full binary tree
class Solution {
public:
bool evaluateTree(TreeNode* root) {
bool retval = true;
if (root->left != nullptr && root->left != nullptr) // full binary tree
{
if (root->val == 2) // OR
{
retval = evaluateTree(root->left) || evaluateTree(root->right);;
}
else // operta = 3, AND
{
retval = evaluateTree(root->left) && evaluateTree(root->right);;
}
}
else
{
retval = root->val;
}
return retval;
}
};
'코딩 문제' 카테고리의 다른 글
[LeetCode] 2032. Two Out of Three, C++ (0) | 2023.01.25 |
---|---|
[Leet Code] 231. Power of Two, C++ (0) | 2023.01.17 |
[LeetCode] 1880. Check if Word Equals Summation of Two Words, C (0) | 2023.01.05 |
[LeetCode] 2406. Divide Intervals Into Minimum Number of Groups, C (0) | 2023.01.02 |
[LeetCode] 1614. Maximum Nesting Depth of the Parenthesesm, C (0) | 2023.01.01 |
Comments