목록이진트리 (20)
넘치게 채우기
https://leetcode.com/problems/reverse-odd-levels-of-binary-tree/description/leetcode - Reverse Odd Levels of Binary Tree문제 유형: 이진트리, bfs문제 난이도: Medium 문제Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2].Return the root of the reversed t..
https://leetcode.com/problems/linked-list-in-binary-tree/description/?envType=daily-question&envId=2024-09-07leetcode - Linked List in Binary Tree문제 유형 : 이진트리, 연결리스트문제 난이도 : Medium 문제Given a binary tree root and a linked list with head as the first node.Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwis..
https://leetcode.com/problems/binary-tree-postorder-traversal/?envType=daily-question&envId=2024-08-25leetcode - Binary Tree Postorder Traversal문제 유형 : 트리, dfs, 이진트리문제 난이도 : Easy 문제Given the root of a binary tree, return the postorder traversal of its nodes' values. 이진트리의 루트가 주어진다, 노드의 값을 후위순회로 한 값을 반환하시오. 풀이후위순회의 순서는, 왼쪽 서브트리 -> 오른쪽 서브트리 -> 루트의 순서이다.이 순서대로 재귀호출 및 로직 처리를 해주면 된다. 코드C++/** * Defin..
https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/description/leetcode - Number of Good Leaf Nodes Paris문제 유형 : 이진트리, 재귀문제 난이도 : Medium 문제You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.Return the number of good leaf..
https://leetcode.com/problems/delete-nodes-and-return-forest/description/leetcode - Delete Nodes And Return Forest문제 유형 : 이진트리, 재귀문제 난이도 : Medium 문제Given the root of a binary tree, each node in the tree has a distinct value.After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees).Return the roots of the trees in the remaining forest. You may retur..
https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another/description/leetcode - Step-By-Step Directions From a Binary Tree Node to Another문제 유형 : 이진트리, 재귀, 백트래킹문제 난이도 : Medium 문제You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node ..
https://leetcode.com/problems/create-binary-tree-from-descriptions/description/leetcode - Create Binary Tree From Descriptions문제 유형 : 이진트리문제 난이도 : Medium 문제You are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a binary tree of unique values. Furthermore,If isLefti == 1, then childi is the left child of ..
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..
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..