목록이진트리 (20)
넘치게 채우기
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..
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..
https://leetcode.com/problems/same-tree/description/ Same Tree - LeetCode Can you solve this real interview question? Same Tree - Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the leetcode.com LeetCode - Same Tree 문제 유형 : 트리, 탐색 문제 난이도 : Easy 문제 Gi..
https://leetcode.com/problems/leaf-similar-trees/description/ Leaf-Similar Trees - LeetCode Can you solve this real interview question? Leaf-Similar Trees - Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. [https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/16/tree.png leetcode.com leetcode - Lear-Similar Trees 문제 유형 : ..
트리는 계층적 관계를 표현하는 자료 구조이다. 뿌리에서 가지를 늘려가며 뻗어가는 모양을 그리는 완전 그래프여서 트리라고 부른다. 회사의 조직도나, 컴퓨터 폴더의 구조에서 트리를 볼 수 있다. 용어 정리 ·노드 node 트리의 구성요소가 되는 정점(A, B, C, D, E, F) ·간선 edge 노드와 노드를 연결하는 연결선 ·루트 root 트리의 최상위 노드(A). 나무의 뿌리와 같은 위치에 있어서 이름이 루트이다. ·단말 노드 terminal node 아래로 또 다른 노드가 연결되어있지 않은 노드이다. 나무의 구조상 잎의 위치여서 잎사귀 노드(leaf node)라고도 한다. ·내부 노드 internal node 단말 노드를 제외한 모든 노드, 비단말 노드(nonterminal node)라고 한다. ·부..