leetcode

    [LeetCode] 1289. Minimum Falling Path Sum II (Daily Question)

    문제Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts. A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column. 2차원 배열 grid가 주어졌을 때, 맨 위(0행)에서 내려가면서 더했을 때 만들 수 있는 최솟값을 구하는 문제이다.단, 내려갈 때는 같은 열로 내려갈 수 없다.  Example 1: Input: grid = [[1,2,3],[4,5..

    [LeetCode] 1137. N-th Tribonacci Number (Daily Question)

    문제The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. Given n, return the value of Tn. T0 = 0, T1 = 1, T2 = 1, Tn+3 = Tn + Tn+1 + Tn+2 이고 n이 주어질 때,Tn을 구하는 문제이다. 피보나치의 업그레이드 버젼인 트리보나치! 이다.Example 1: Input: n = 4 Output: 4 Explanation: T_3 = 0 + 1 + 1 = 2 T_4 = 1 + 1 + 2 = 4 Example 2:Input: n = 25 Output: 1389537 풀이아이디어리스트..

    [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] 752. Open the Lock (Daily Question)

    문제 You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move consists of turning one wheel one slot. The lock initially starts at '0000', a string representing the state of the 4 wheels. You are given a list of d..

    [LeetCode] 1971. Find if Path Exists in Graph (Daily Question)

    문제 There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. You want to determine if there is a v..

    [LeetCode] 1992. Find All Groups of Farmland (Daily Question)

    문제 You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland. To keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to a..