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 | 31 |
Tags
- Class
- 코딩테스트
- Stack
- implement
- dynamic programming
- Data Structure
- hash table
- Counting
- database
- array
- Number Theory
- 코테
- two pointers
- Binary Search
- bit manipulation
- Method
- 구현
- 파이썬
- 자바
- Binary Tree
- Matrix
- SQL
- string
- java
- Tree
- sorting
- geometry
- simulation
- greedy
- Math
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2236. Root Equals Sum of Children 본문
1. Input
1) 이진 트리 root
- 부모 1개(root node), 자식 2개(right/left child node)로 이루어진 트리다.
2. Output
1) 부모 노드의 값이 자식 노드의 값의 합과 같으면 true, 다르면 false를 반환
3. Constraint
1) -100 <= Node.val <= 100
4. Example
Input: root = [10,4,6] -> Output: true
설명: 10 = 4 + 6
5. Code
1) 첫 코드(2022/06/01)
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
return root.val == root.left.val + root.right.val ? true : false;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2264. Largest 3-Same-Digit Number in String (0) | 2023.01.16 |
---|---|
[LeetCode/Easy] 2255. Count Prefixes of a Given String (0) | 2023.01.16 |
[LeetCode/Easy] 2235. Add Two Integers (0) | 2023.01.16 |
[LeetCode/Easy] 2224. Minimum Number of Operations to Convert Time (0) | 2023.01.15 |
[LeetCode/Easy] 2220. Minimum Bit Flips to Convert Number (0) | 2023.01.15 |