Tree
[LeetCode] 310. Minimum Height Trees (Daily Question)
문제 A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes labelled from 0 to n - 1, and an array of n - 1 edges where edges[i] = [ai, bi] indicates that there is an undirected edge between the two nodes ai and bi in the tree, you can choose any node of the tree as the ..
![[LeetCode] 988. Smallest String Starting From Leaf (Daily Question)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FyYBpD%2FbtsGIdQJ2Vv%2FHrEBLBYtedV3jBuCgq9Wb0%2Fimg.png)
[LeetCode] 988. Smallest String Starting From Leaf (Daily Question)
문제 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 reminder, any shorter prefix of a string is lexicographically smaller. - For example, "ab" is lexicographically smaller than "aba". A leaf of a node is a node tha..
![[LeetCode] 623. Add One Row to Tree (Daily Question)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb5sbIh%2FbtsGFm8AdC0%2FIH8zyXRDJVcNkxxWk1zYKk%2Fimg.png)
[LeetCode] 623. Add One Row to Tree (Daily Question)
문제 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, create two tree nodes with value val as cur's left subtree root and right subtree root. - cur's original left subtree should be t..
![[LeetCode] 129. Sum Root to Leaf Numbers (Daily Question)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FF9qHo%2FbtsGBcGpXsK%2FR4wLcGPA7zCFNdn5CCRkL1%2Fimg.png)
[LeetCode] 129. Sum Root to Leaf Numbers (Daily Question)
문제 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. Test cases are generated so that the answer will fit in a 32-bit integer. A leaf node is a node with no children. 이진트리가 주어졌을 때, leaf노드에서 ..
![[LeetCode] 404. Sum of Left Leaves (Daily Question)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcNH34z%2FbtsGBOykyRS%2FwlI8HlXe0iKZ6pfkZ0C4S0%2Fimg.png)
[LeetCode] 404. Sum of Left Leaves (Daily Question)
문제 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. 이진트리가 주어졌을 때, 왼쪽 leaf node의 값의 합을 구하는 문제이다. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 24 Explanation: There are two left leaves in the binary tree, with values 9 and 15 respectively. Example 2: Input: root = [1] Outp..