목록전체 글 (1209)
넘치게 채우기
https://leetcode.com/problems/maximum-number-of-k-divisible-components/description/leetcode - Maximum Number of K-Divisible Components문제 유형: 트리, dfs, 부분합문제 난이도: Hard 문제There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the t..
https://www.acmicpc.net/problem/2467BOJ - 용액문제 유형: 투 포인터문제 난이도: Gold V시간 제한: 1초메모리 제한: 128MB 문제KOI 부설 과학연구소에서는 많은 종류의 산성 용액과 알칼리성 용액을 보유하고 있다. 각 용액에는 그 용액의 특성을 나타내는 하나의 정수가 주어져있다. 산성 용액의 특성값은 1부터 1,000,000,000까지의 양의 정수로 나타내고, 알칼리성 용액의 특성값은 -1부터 -1,000,000,000까지의 음의 정수로 나타낸다.같은 양의 두 용액을 혼합한 용액의 특성값은 혼합에 사용된 각 용액의 특성값의 합으로 정의한다. 이 연구소에서는 같은 양의 두 용액을 혼합하여 특성값이 0에 가장 가까운 용액을 만들려고 한다. 예를 들어, 주어진 용액들의..
https://leetcode.com/problems/reverse-odd-levels-of-binary-tree/description/leetcode - Reverse Odd Levels of Binary Tree문제 유형: 이진트리, bfs문제 난이도: Medium 문제Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2].Return the root of the reversed t..
https://www.acmicpc.net/problem/2166BOJ - 다각형의 면적문제 유형: 수학, 선형대수, 기하학문제 난이도: Gold V시간 제한: 2초메모리 제한: 128MB 문제2차원 평면상에 N(3 ≤ N ≤ 10,000)개의 점으로 이루어진 다각형이 있다. 이 다각형의 면적을 구하는 프로그램을 작성하시오. 입력첫째 줄에 N이 주어진다. 다음 N개의 줄에는 다각형을 이루는 순서대로 N개의 점의 x, y좌표가 주어진다. 좌표값은 절댓값이 100,000을 넘지 않는 정수이다. 출력첫째 줄에 면적을 출력한다. 면적을 출력할 때에는 소수점 아래 둘째 자리에서 반올림하여 첫째 자리까지 출력한다. 풀이볼록 또는 오목다각형에서 순서대로 N개의 점의 좌표가 주어진다면, 신발끈 공식을 이용해서 다각형의..
https://leetcode.com/problems/max-chunks-to-make-sorted/description/leetcode - Max Chunks To Make Sorted문제 유형: 그리디, 브루트 포스문제 난이도: Medium 문제You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1].We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equa..
https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/description/leetcode - Final Prices With a Special Discount in a Shop문제 유형: 구현문제 난이도: Easy 문제You are given an integer array prices where prices[i] is the price of the ith item in a shop.There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] wh..
https://www.acmicpc.net/problem/13412BOJ - 서로소 쌍문제 유형: 수학문제 난이도: Silver II시간 제한: 1초메모리 제한: 128MB 문제두 자연수 A, B의 최대공약수를 GCD(A, B)라고 할 때, A와 B가 서로소면 GCD(A, B) = 1이다. 두 자연수 A, B의 최소공배수를 LCM(A, B)라고 할 때, A와 B가 서로소면 LCM(A, B) = A x B이다.어떤 자연수 N이 서로소인 두 자연수 A, B의 최소공배수라고 할 때, A, B로 가능한 숫자 쌍은 여러 개가 있을 수 있다. 예를 들어 N = 30인 경우 30을 최소공배수로 하는 서로소인 두 자연수로 가능한 숫자 쌍은 (1, 30), (2, 15), (3, 10), (5, 6)의 4가지가 있다.자..
https://www.acmicpc.net/problem/2713BOJ - 규현이의 사랑을 담은 문자메시지문제 유형: 행렬, 구현, 문자열 처리문제 난이도: Silver I시간 제한: 1초메모리 제한: 128MB 문제규현이는 승환이에게 사랑을 담은 문자 메시지를 자주 보낸다. 이것을 남에게 보이기 싫었던 규현이는 승환이와 비밀 규칙을 만들었다.규현이는 비밀 메시지를 만들기 위한 행렬의 행의 수 R과 열의 수 C를 정했다. 그 다음 다음과 같은 규칙으로 비밀 메시지를 만든다.모든 글자는 알파벳 대문자와 공백으로 이루어져 있다.글자는 다음과 같이 숫자로 바뀐다. 공백 = 0, A = 1, B = 2, ..., Y = 25, Z = 26먼저 규현이는 문자를 위 규칙을 이용해 글자를 숫자로 바꾼 다음에 이것은 ..
https://leetcode.com/problems/construct-string-with-repeat-limit/description/leetcode - Construct String With Repeat Limit문제 유형: 우선순위 큐, 그리디, 문자열 처리문제 난이도: Medium 문제You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s...
https://www.acmicpc.net/problem/6772BOJ - Choose Your Own Arithmetic문제 유형: 수학, 다이나믹 프로그래밍, dfs, 재귀, 백트래킹문제 난이도: Silver I시간 제한: 2초메모리 제한: 512MB 문제In Waterloo, you probably have seen some geese. How can you see geese with your calculator? Start with 6, add 7, multiply by 6, multiply by 8, add 7, multiply by 8, and multiply by 7, giving 35336. Then if you flip your calculator upside down, it says g..