목록PS/LeetCode (586)
넘치게 채우기
https://leetcode.com/problems/open-the-lock/description/ Leetcode - Open the Lock 문제 유형 : dfs/bfs, 문자열 처리 문제 난이도 : Medium 문제 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..
https://leetcode.com/problems/find-if-path-exists-in-graph/description/ Leetcode - Find if Path Exists in Graph 문제 유형 : 그래프, dfs / bfs 문제 난이도 : Easy 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 verte..
https://leetcode.com/problems/find-all-groups-of-farmland/description/ Leetcode - Find All Groups of Farmland 문제 유형 : dfs/bfs, 행렬 문제 난이도 : Medium 문제 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 farm..
https://leetcode.com/problems/number-of-islands/description/ LeetCode - Number of Islands 문제 유형 : dfs/bfs, 행렬 문제 난이도 : Medium 문제 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 ar..
https://leetcode.com/problems/island-perimeter/description/ LeetCode - Island Perimeter 문제 유형 : 행렬 문제 난이도 : Easy 문제 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 mor..
https://leetcode.com/problems/smallest-string-starting-from-leaf/description/ Leetcode - Smallest String Starting From Leaf 문제 유형 : 이진트리, 재귀, dfs 문제 난이도 : Medium 문제 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 ..
https://leetcode.com/problems/add-one-row-to-tree/description/ LeetCode - Add One Row to Tree 문제 유형 : 이진트리, dfs, 재귀 문제 난이도 : Medium 문제 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,..
https://leetcode.com/problems/sum-root-to-leaf-numbers/description/ Leetcode - Sum Root to Leaf Numbers 문제 유형 : dfs, 이진트리 문제 난이도 : Medium 문제 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. T..
https://leetcode.com/problems/sum-of-left-leaves/description/ Leetcode - Sum of Left Leaves 문제 유형 : 이진 트리, dfs, 재귀 문제 난이도 : Easy 문제 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. 이진 트리의 루트가 주어진다. 모든 왼쪽 잎 노드의 값의 합을 구하시오. 잎 노드란 자식 노드가 없는 노드를 말합니다. 풀이 말 그대로 이진트리를 순회하면서 왼쪽 리프노드의 합을 반..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/DLgl2/btsGBRuuDau/3VGkIZVHkY6vPASkSbr0z0/img.png)
https://leetcode.com/problems/maximal-rectangle/description/ Leetcode - Maximal Rectangle 문제 유형 : 히스토그램, 스택, 다이나믹 프로그래밍 문제 난이도 : Hard 문제 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. rows x cols크기의 이진 행렬이 주어진다. 1로만 이루어진 가장 큰 직사각형을 찾아서 그 크기를 반환하시오. 풀이 풀이 1: 다이나믹 프로그래밍(동적계획법) 처음에는 각 자리별로 1로 이어진 왼쪽 끝과 위쪽 끝을 구한 뒤, 크기를 일..