목록DFS (93)
넘치게 채우기
https://www.acmicpc.net/problem/16964BOJ - DFS 스페셜 저지문제 유형: DFS/BFS문제 난이도: Gold III시간 제한: 2초메모리 제한: 512MB 문제BOJ에서 정답이 여러가지인 경우에는 스페셜 저지를 사용한다. 스페셜 저지는 유저가 출력한 답을 검증하는 코드를 통해서 정답 유무를 결정하는 방식이다. 오늘은 스페셜 저지 코드를 하나 만들어보려고 한다.정점의 개수가 N이고, 정점에 1부터 N까지 번호가 매겨져있는 양방향 그래프가 있을 때, DFS 알고리즘은 다음과 같은 형태로 이루어져 있다.void dfs(int x) { if (check[x] == true) { return; } check[x] = true; // x를 방문 ..
https://www.acmicpc.net/problem/3485BOJ - Play on Words문제 유형: 그래프 이론, 오일러 경로, 오일러 회로, dfs문제 난이도: Gold III시간 제한: 1초메모리 제한: 256MB 문제Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us.There is a large number of magnetic plates on every doo..
https://www.acmicpc.net/problem/6907BOJ - Floor Plan문제 유형: BFS, DFS, 그래프, 정렬문제 난이도: Silver I시간 제한: 1초메모리 제한: 128MB 문제The floor plan of a house shows rooms separated by walls. This floor plan can be transferred to a grid using the character I for walls and . for room space. Doorways are not shown. Each I or . character occupies one square metre.In this diagram, there are six rooms.You have been g..
https://leetcode.com/problems/extra-characters-in-a-string/description/?envType=daily-question&envId=2024-09-23leetcode - Extra Characters in a String문제 유형 : 문자열 처리, 재귀, dp문제 난이도 : Medium 문제You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some ex..
https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/description/?envType=daily-question&envId=2024-09-22leetcode - K-th Smallest in Lexicographical Order문제 유형 : 트리, dfs, 수학문제 난이도 : Hard 문제Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n]. 두 개의 정수 n과 k가 주어진다. 범위 [1,n]에서 사전순으로 k번째로 작은 정수를 반환하시오. 풀이순차적으로 k개를 찾는 것은 느리다.대신, 점프를 할 필요가 있다..
https://leetcode.com/problems/lexicographical-numbers/description/?envType=daily-question&envId=2024-09-21leetcode - Lexicographical Numbers문제 유형 : 수학, 구현, dfs, 재귀문제 난이도 : Medium 문제Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.You must write an algorithm that runs in O(n) time and uses O(1) extra space. 정수 n이 주어진다. [1, n]의 모든 숫자들을 사전순으로 정렬하여 반환하시..
https://www.acmicpc.net/problem/11183BOJ - Coast Length문제 유형 : BFS, DFS, 행렬, 구현문제 난이도 : Silver I 문제The island municipality of Soteholm is required to write a plan of action for their work with emission of greenhouse gases. They realize that a natural first step is to decide whether they are for or against global warming. For this purpose they have read the IPCC report on climate change and found..
https://leetcode.com/problems/count-sub-islands/description/?envType=daily-question&envId=2024-08-28leetcode - Count Sub Islands문제 유형 : bfs/dfs, 행렬문제 난이도 : Medium 문제You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the gr..
https://leetcode.com/problems/n-ary-tree-postorder-traversal/description/?envType=daily-question&envId=2024-08-26leetcode - N-ary Tree Postorder Traversal문제 유형 : 트리, dfs, 재귀, 스택문제 난이도 : Easy 문제Given the root of an n-ary tree, return the postorder traversal of its nodes' values.Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the ..
https://leetcode.com/problems/combination-sum-ii/description/?envType=daily-question&envId=2024-08-13leetcode - Combination Sum II문제 유형 : 백트래킹, dfs, 재귀문제 난이도 : Medium 문제Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target.Each number in candidates may only be used once in the combin..