leetcode

    [LeetCode] 200. Number of Islands (Daily Question)

    문제 Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. 바다를 의미하는 0과 섬의 땅을 의미하는 1로 구성된 2차원 배열 grid가 주어졌을 때, 섬 해안선의 길이를 구하는 문제이다. Example 1: Input: grid =[ [..

    [LeetCode] 463. Island Perimeter (Daily Question)

    [LeetCode] 463. Island Perimeter (Daily Question)

    문제 You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). The island doesn't have "lakes", meaning the water inside isn't connected to the water a..

    [LeetCode] 988. Smallest String Starting From Leaf (Daily Question)

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

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