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%2Fdna%2FyYBpD%2FbtsGIdQJ2Vv%2FAAAAAAAAAAAAAAAAAAAAAJtrPCQk0EO2nxmTfXzgVM7Eo7i3YU7OQYVwF2sTW1uf%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1761922799%26allow_ip%3D%26allow_referer%3D%26signature%3Dujacmm4cpPt88bsgBCvyOxsYwW4%253D)
[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%2Fdna%2Fb5sbIh%2FbtsGFm8AdC0%2FAAAAAAAAAAAAAAAAAAAAAH7Ps3UAwgSKzX7Lc59wGccAq2CKl4X9d4wzVdTTrmQG%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1761922799%26allow_ip%3D%26allow_referer%3D%26signature%3DSezxuOVCf7KcxpoJR7QJizJDgrA%253D)
[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%2Fdna%2FF9qHo%2FbtsGBcGpXsK%2FAAAAAAAAAAAAAAAAAAAAAN2rZxCZFqpXuxBNRlJpXK-3YeO5K4UBdCZIEEy1QTh0%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1761922799%26allow_ip%3D%26allow_referer%3D%26signature%3DF6vouQKUCHstCmjbeemtAs2WyUE%253D)
[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%2Fdna%2FcNH34z%2FbtsGBOykyRS%2FAAAAAAAAAAAAAAAAAAAAANSq48XtXSryCPgGYcMMCLrquvUamNpD-r4bYj8tnMjt%2Fimg.png%3Fcredential%3DyqXZFxpELC7KVnFOS48ylbz2pIh7yKj8%26expires%3D1761922799%26allow_ip%3D%26allow_referer%3D%26signature%3DNOaS1C7SyyB3iPr7KFqHHMO8cTA%253D)
[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..