목록DFS (80)
넘치게 채우기
https://leetcode.com/problems/the-number-of-beautiful-subsets/description/leetcode - The Number of Beautiful Subsets문제 유형 : 백트래킹, dfs, 재귀문제 난이도 : Medium 문제You are given an array nums of positive integers and a positive integer k.A subset of nums is beautiful if it does not contain two integers with an absolute difference equal to k.Return the number of non-empty beautiful subsets of the array nu..
https://leetcode.com/problems/palindrome-partitioning/description/leetcode - Palindrome Partitioning문제 유형 : 문자열 처리, 재귀, dfs, 백트래킹문제 난이도 : Medium 문제Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. 문자열 s가 주어진다.모든 (s를 쪼갠 조각들이 팰린드롬 문자열)인 집합들을 반환하시오. ex-> "aab"는 ["a", "a", "b"]로 나누면 모두 팰린드롬인 문자열들로 나눈 것입니다. 풀이재귀..
https://leetcode.com/problems/distribute-coins-in-binary-tree/description/leetcode - Distribute Coins in Binary Tree문제 유형 : 이진트리, dfs, 재귀, 부분합문제 난이도 : Medium 문제You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole tree.In one move, we may choose two adjacent nodes and move one coin from one node to an..
https://leetcode.com/problems/delete-leaves-with-a-given-value/description/leetcode - Delete Leaves With a Given Value문제 유형 : 이진트리, dfs, 재귀문제 난이도 : Medium 문제Given a binary tree root and an integer target, delete all the leaf nodes with value target.Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (..
https://leetcode.com/problems/evaluate-boolean-binary-tree/description/leetcode - Evaluate Boolean Binary Tree문제 유형 : 이진트리, dfs, 재귀문제 난이도 : Easy 문제You are given the root of a full binary tree with the following properties:Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 rep..
https://leetcode.com/problems/path-with-maximum-gold/description/leetcode - Path with Maximum Gold문제 유형 : dfs, 백트래킹, 행렬, 재귀문제 난이도 : Medium 문제In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.Return the maximum amount of gold you can collect under the conditions:Every time you are located in a cell you will coll..
https://leetcode.com/problems/sum-of-distances-in-tree/description/leetcode - Sum of Distances in Tree문제 유형 : dfs, 재귀, 트리, 다이나믹 프로그래밍문제 난이도 : Hard 문제There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.Return an array ..
https://leetcode.com/problems/freedom-trail/description/leetcode - Freedom Trail문제 유형 : 재귀 / dfs / 다이나믹 프로그래밍문제 난이도 : Hard 문제In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to spell a specific keyword to open the door.Given a string ring that represents the code engraved on the outer ring and another..
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..