목록PS (869)
넘치게 채우기
https://www.acmicpc.net/problem/11725BOJ - 트리의 부모 찾기문제 유형: 트리, bfs문제 난이도: Silver II시간 제한: 1초메모리 제한: 256MB 문제루트 없는 트리가 주어진다. 이때, 트리의 루트를 1이라고 정했을 때, 각 노드의 부모를 구하는 프로그램을 작성하시오. 입력첫째 줄에 노드의 개수 N (2 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N-1개의 줄에 트리 상에서 연결된 두 정점이 주어진다. 출력첫째 줄부터 N-1개의 줄에 각 노드의 부모 노드 번호를 2번 노드부터 순서대로 출력한다. 풀이연결 관계만 주어지므로, 정확한 계층 관계를 알 수는 없다.그래서, bfs를 하면서 방문처리를 하며 부모자식 관계를 지어주어야 한다.1부터 bfs를 시작하면..
https://leetcode.com/problems/kth-largest-sum-in-a-binary-tree/description/?envType=daily-question&envId=2024-10-22leetcode - Kth Largest Sum in a Binary Tree문제 유형: BFS, 우선순위 큐문제 난이도: Medium 문제You are given the root of a binary tree and a positive integer k.The level sum in the tree is the sum of the values of the nodes that are on the same level.Return the kth largest level sum in the tree (not..
https://www.acmicpc.net/problem/11053BOJ - 가장 긴 증가하는 부분 수열문제 유형: 다이나믹 프로그래밍, LIS(가장 긴 증가하는 부분 수열), 이진 탐색문제 난이도: Silver II시간 제한: 1초메모리 제한: 256MB 문제수열 A가 주어졌을 때, 가장 긴 증가하는 부분 수열을 구하는 프로그램을 작성하시오.예를 들어, 수열 A = {10, 20, 10, 30, 20, 50} 인 경우에 가장 긴 증가하는 부분 수열은 A = {10, 20, 10, 30, 20, 50} 이고, 길이는 4이다. 입력첫째 줄에 수열 A의 크기 N (1 ≤ N ≤ 1,000)이 주어진다.둘째 줄에는 수열 A를 이루고 있는 Ai가 주어진다. (1 ≤ Ai ≤ 1,000) 출력첫째 줄에 수열 A의..
https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/description/?envType=daily-question&envId=2024-10-21leetcode - Split a String Into the Max Number of Unique Substrings문제 유형: 백트래킹, 재귀, dfs, 해시, 문자열 처리문제 난이도: Medium 문제Given a string s, return the maximum number of unique substrings that the given string can be split into.You can split string s into any list of ..
https://www.acmicpc.net/problem/15650BOJ - N과 M(2)문제 유형: 백트래킹, dfs, 재귀문제 난이도: Silver III시간 제한: 1초메모리 제한: 512MB 문제자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열고른 수열은 오름차순이어야 한다. 입력첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) 출력한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다.수열은 사전 순으로 증가하는 순서로 출력해야 한다.풀이배열을 (1, 2, ...,n-1 , n)..
https://leetcode.com/problems/parsing-a-boolean-expression/description/?envType=daily-question&envId=2024-10-20leetcode - Parsing A Boolean Expression문제 유형: 문자열 처리, 스택, 구현문제 난이도: Hard 문제A boolean expression is an expression that evaluates to either true or false. It can be in one of the following shapes:'t' that evaluates to true.'f' that evaluates to false.'!(subExpr)' that evaluates to the log..
https://www.acmicpc.net/problem/15666BOJ - N과 M(12)문제 유형: DFS, 재귀, 백트래킹문제 난이도: Silver II시간 제한: 2초메모리 제한: 512MB 문제N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오.N개의 자연수 중에서 M개를 고른 수열같은 수를 여러 번 골라도 된다.고른 수열은 비내림차순이어야 한다.길이가 K인 수열 A가 A1 ≤ A2 ≤ ... ≤ AK-1 ≤ AK를 만족하면, 비내림차순이라고 한다. 입력첫째 줄에 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8)둘째 줄에 N개의 수가 주어진다. 입력으로 주어지는 수는 10,000보다 작거나 같은 자연수이다. 출력한 줄에 하나씩 문..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/3qulX/btsKcjnivOD/jkxCNKMeHmTOwqAXfRdpyK/img.jpg)
https://leetcode.com/problems/find-kth-bit-in-nth-binary-string/description/leetcode - Find Kth Bit in Nth Binary String문제 유형: 비트 조작, 재귀, 문자열 처리문제 난이도: Medium 문제Given two positive integers n and k, the binary string Sn is formed as follows:S1 = "0"Si = Si - 1 + "1" + reverse(invert(Si - 1)) for i > 1Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/sqsdc/btsKbhPWBpw/OpulBKICzzPocgOUmYFySk/img.png)
https://www.acmicpc.net/problem/18405BOJ - 경쟁적 전염문제 유형: bfs, 그리디문제 난이도: Gold V시간 제한: 1초메모리 제한: 256MB 문제NxN 크기의 시험관이 있다. 시험관은 1x1 크기의 칸으로 나누어지며, 특정한 위치에는 바이러스가 존재할 수 있다. 모든 바이러스는 1번부터 K번까지의 바이러스 종류 중 하나에 속한다.시험관에 존재하는 모든 바이러스는 1초마다 상, 하, 좌, 우의 방향으로 증식해 나간다. 단, 매 초마다 번호가 낮은 종류의 바이러스부터 먼저 증식한다. 또한 증식 과정에서 특정한 칸에 이미 어떠한 바이러스가 존재한다면, 그 곳에는 다른 바이러스가 들어갈 수 없다.시험관의 크기와 바이러스의 위치 정보가 주어졌을 때, S초가 지난 후에 (X,..
https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/description/leetcode - Count Number of Maximum Bitwise-OR Subsets문제 유형: dfs, 재귀, 브루트 포스, 백트래킹, 완전탐색, 비트마스킹문제 난이도: Medium 문제Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.An array a is a subset of an array ..