목록이진트리 (13)
넘치게 채우기
https://leetcode.com/problems/balance-a-binary-search-tree/description/leetcode - Balance a Binary Search Tree문제 유형 : 트리, 재귀, 이진트리, 이진탐색트리문제 난이도 : Medium 문제Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.A binary search tree is balanced if the depth of the two subtrees of every node never..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/O8ThZ/btsIbrHqjCF/8ClLwSx0wtLYKx8cuTK0lK/img.png)
https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/description/leetcode - Binary Search Tree to Greater Sum Tree문제 유형 : 이진트리, 이진탐색트리, dfs문제 난이도 : Medium 문제Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.As a reminder, a ..
https://leetcode.com/problems/distribute-coins-in-binary-tree/description/leetcode - Distribute Coins in Binary Tree문제 유형 : 이진트리, dfs, 재귀, 부분합문제 난이도 : Medium 문제You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree.In one move, we may choose two adjacent nodes and move one coin from one node to an..
https://leetcode.com/problems/evaluate-boolean-binary-tree/description/leetcode - Evaluate Boolean Binary Tree문제 유형 : 이진트리, dfs, 재귀문제 난이도 : Easy 문제You are given the root of a full binary tree with the following properties:Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 rep..
https://leetcode.com/problems/smallest-string-starting-from-leaf/description/ Leetcode - Smallest String Starting From Leaf 문제 유형 : 이진트리, 재귀, dfs 문제 난이도 : Medium 문제 You are given the root of a binary tree where each node has a value in the range [0, 25] representing the letters 'a' to 'z'. Return the lexicographically smallest string that starts at a leaf of this tree and ends at the root. As a ..
https://leetcode.com/problems/add-one-row-to-tree/description/ LeetCode - Add One Row to Tree 문제 유형 : 이진트리, dfs, 재귀 문제 난이도 : Medium 문제 Given the root of a binary tree and two integers val and depth, add a row of nodes with value val at the given depth depth. Note that the root node is at depth 1. The adding rule is: Given the integer depth, for each not null tree node cur at the depth depth - 1,..
https://leetcode.com/problems/sum-root-to-leaf-numbers/description/ Leetcode - Sum Root to Leaf Numbers 문제 유형 : dfs, 이진트리 문제 난이도 : Medium 문제 You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the total sum of all root-to-leaf numbers. T..
https://leetcode.com/problems/sum-of-left-leaves/description/ Leetcode - Sum of Left Leaves 문제 유형 : 이진 트리, dfs, 재귀 문제 난이도 : Easy 문제 Given the root of a binary tree, return the sum of all left leaves. A leaf is a node with no children. A left leaf is a leaf that is the left child of another node. 이진 트리의 루트가 주어진다. 모든 왼쪽 잎 노드의 값의 합을 구하시오. 잎 노드란 자식 노드가 없는 노드를 말합니다. 풀이 말 그대로 이진트리를 순회하면서 왼쪽 리프노드의 합을 반..
https://leetcode.com/problems/even-odd-tree/description/ LeetCode - Even Odd Tree 문제 유형 : 이진트리 문제 난이도 : Medium 문제 A binary tree is named Even-Odd if it meets the following conditions: The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc. For every even-indexed level, all nodes at the level have odd integer values in strictly..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ymT90/btsFkIk56VE/ShvG4rDKRHoWzziLKpwIXK/img.png)
https://leetcode.com/problems/diameter-of-binary-tree/description/ Diameter of Binary Tree - LeetCode Can you solve this real interview question? Diameter of Binary Tree - Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path leetcode.com Leetcode - Diameter of Bin..