전체 글

전체 글

    [LeetCode] 623. Add One Row to Tree (Daily Question)

    [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)

    [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)

    [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..

    [LeetCode] 85. Maximal Rectangle (Daily Question)

    [LeetCode] 85. Maximal Rectangle (Daily Question)

    문제 Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. 0과 1로 이루어진 테이블이 주어졌을 때, 1로 만들 수 있는 가장 큰 사각형의 넓이를 구하는 문제이다. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 6 Explanation: The maximal rectangle is shown in the above picture. Example 2: Input..

    [LeetCode] 42. Trapping Rain Water (Daily Question)

    [LeetCode] 42. Trapping Rain Water (Daily Question)

    문제 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. 다양한 높이의 기둥들이 주어진다. 이 때 비가오게 된다면 차게 될 물의 양을 구하는 문제이다. Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain w..

    [LeetCode] 402. Remove K Digits (Daily Question)

    문제 Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. 숫자 문자열 num에서 k개의 digit(0-9)을 없애서 가장 작은 수를 만드는 문제이다. Example 1: Input: num = "1432219", k = 3 Output: "1219" Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest. Example 2: Input: num = "10200", k = 1 O..