본문 바로가기

트리5

LeetCode 116(Populating Next Right Pointers in Each Node, java) 0. 문제 https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ Populating Next Right Pointers in Each Node - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 완전 이진트리(root)가 주어진다. - 모든 노드는 next 속성이 있는데, 이는 우측 노드를 가리키는 포인터 역할을 한다. - 모든 노드의 next 값은 nul.. 2022. 4. 29.
LeetCode 617(Merge Two Binary Trees, java) 0. 문제 https://leetcode.com/problems/merge-two-binary-trees/ Merge Two Binary Trees - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리 2개(root1, root2)가 주어진다. - 두 이진트리를 병합하여 하나의 이진트리를 반환하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 두 트리의 노드를 탐색하여, 각 노드의 값을 병합하는 과정을.. 2022. 4. 28.
LeetCode 235(Lowest Common Ancestor of a Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ Lowest Common Ancestor of a Binary Search Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진 탐색 트리(root)와 두 개의 노드(p, q)가 주어진다. - 주어진 두 개의 노드(p, q) 사이에 존재하는 노드 중 가장 작은 값을 가지는 노.. 2022. 4. 22.
LeetCode 653(Two Sum IV - Input is a BST, java) 0. 문제 https://leetcode.com/problems/two-sum-iv-input-is-a-bst/ Two Sum IV - Input is a BST - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진 탐색 트리(root)와 찾는 수(k)가 주어진다. - 트리를 구성하는 노드 중 2개 노드의 value 합이 찾는 수인 경우가 존재하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 우선 모든 .. 2022. 4. 22.
LeetCode 98(Validate Binary Search Tree, java) 0. 문제 https://leetcode.com/problems/validate-binary-search-tree/ Validate Binary Search Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. 문제 설명 - 문제에서 이진트리(root)가 주어진다. - 주어진 이진트리가 이진 탐색 트리를 만족하는지 판단하는 것이 문제의 핵심이다. 2. 문제 해설 a) 첫 번째 접근 - 이 문제는 이진 탐색 트리의 조건을 만족하는지를 판단하는 문제다. .. 2022. 4. 22.