목록2025/02 (65)
넘치게 채우기
https://leetcode.com/problems/remove-all-occurrences-of-a-substring/description/leetcode - Remove All Occurrences of a Substring문제 유형: 스택, 문자열 처리문제 난이도: Medium 문제Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:Find the leftmost occurrence of the substring part and remove it from s.Return s after removing all occurrences o..
https://www.acmicpc.net/problem/2644BOJ - 촌수계산문제 유형: bfs, 최단경로문제 난이도: Silver II시간 제한: 1초메모리 제한: 128MB 문제우리 나라는 가족 혹은 친척들 사이의 관계를 촌수라는 단위로 표현하는 독특한 문화를 가지고 있다. 이러한 촌수는 다음과 같은 방식으로 계산된다. 기본적으로 부모와 자식 사이를 1촌으로 정의하고 이로부터 사람들 간의 촌수를 계산한다. 예를 들면 나와 아버지, 아버지와 할아버지는 각각 1촌으로 나와 할아버지는 2촌이 되고, 아버지 형제들과 할아버지는 1촌, 나와 아버지 형제들과는 3촌이 된다.여러 사람들에 대한 부모 자식들 간의 관계가 주어졌을 때, 주어진 두 사람의 촌수를 계산하는 프로그램을 작성하시오. 입력사람들은 1, ..

https://www.acmicpc.net/problem/6549BOJ - 히스토그램에서 가장 큰 직사각형문제 유형: 히스토그램, 스택(모노토닉 스택), 세그먼트 트리, 분할 정복, 투 포인터문제 난이도: Platinum V시간 제한: 1초메모리 제한: 256MB 문제히스토그램은 직사각형 여러 개가 아래쪽으로 정렬되어 있는 도형이다. 각 직사각형은 같은 너비를 가지고 있지만, 높이는 서로 다를 수도 있다. 예를 들어, 왼쪽 그림은 높이가 2, 1, 4, 5, 1, 3, 3이고 너비가 1인 직사각형으로 이루어진 히스토그램이다.히스토그램에서 가장 넓이가 큰 직사각형을 구하는 프로그램을 작성하시오. 입력입력은 테스트 케이스 여러 개로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, 직사각형의 수 ..
https://leetcode.com/problems/clear-digits/description/leetcode - Clear Digits문제 유형: 스택, 문자열 처리문제 난이도: Easy 문제You are given a string s.Your task is to remove all digits by doing this operation repeatedly:Delete the first digit and the closest non-digit character to its left.Return the resulting string after removing all digits. 문자열 s를 받습니다.당신의 임무는 다음을 반복적으로 수행하는 것 입니다:첫 번째 숫자를 지우고 왼쪽의 숫자가 아닌 문자를..
1https://www.acmicpc.net/problem/1565492https://www.acmicpc.net/problem/156503https://www.acmicpc.net/problem/156514https://www.acmicpc.net/problem/156525https://www.acmicpc.net/problem/156546https://www.acmicpc.net/problem/156557https://www.acmicpc.net/problem/156568https://www.acmicpc.net/problem/156579https://www.acmicpc.net/problem/1566310https://www.acmicpc.net/problem/1566411https://www.ac..
https://leetcode.com/problems/count-number-of-bad-pairs/description/leetcode - Count Number of Bad Pairs문제 유형: 투 포인터, 해시, 정렬, 수학문제 난이도: Medium 문제You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i and j - i != nums[j] - nums[i].Return the total number of bad pairs in nums. 0-indexed의 정수 배열 nums가 주어진다.(i, j)페어는 다음 조건을 만족하면 나쁜 페어이다: if i 나쁜 페어의 개수를 구하시오. 풀이전체..
https://www.acmicpc.net/problem/2042BOJ - 구간 합 구하기문제 유형: 세그먼트 트리문제 난이도: Gold I시간 제한: 2초메모리 제한: 256MB 문제어떤 N개의 수가 주어져 있다. 그런데 중간에 수의 변경이 빈번히 일어나고 그 중간에 어떤 부분의 합을 구하려 한다. 만약에 1,2,3,4,5 라는 수가 있고, 3번째 수를 6으로 바꾸고 2번째부터 5번째까지 합을 구하라고 한다면 17을 출력하면 되는 것이다. 그리고 그 상태에서 다섯 번째 수를 2로 바꾸고 3번째부터 5번째까지 합을 구하라고 한다면 12가 될 것이다. 입력첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000,000)과 M(1 ≤ M ≤ 10,000), K(1 ≤ K ≤ 10,000) 가 주어진다. M은 수의 ..
https://leetcode.com/problems/design-a-number-container-system/description/leetcode - Design a Number Container System문제 유형: 우선순위 큐, 힙, 해시문제 난이도: Medium 문제Design a number container system that can do the following:Insert or Replace a number at the given index in the system.Return the smallest index for the given number in the system.Implement the NumberContainers class:NumberContainers() Initial..

https://www.acmicpc.net/problem/2263BOJ - 트리의 순회문제 유형: 트리, dfs, 분할 정복문제 난이도: Gold I시간 제한: 5초메모리 제한: 128MB 문제n개의 정점을 갖는 이진 트리의 정점에 1부터 n까지의 번호가 중복 없이 매겨져 있다. 이와 같은 이진 트리의 인오더와 포스트오더가 주어졌을 때, 프리오더를 구하는 프로그램을 작성하시오. 입력첫째 줄에 n(1 ≤ n ≤ 100,000)이 주어진다. 다음 줄에는 인오더를 나타내는 n개의 자연수가 주어지고, 그 다음 줄에는 같은 식으로 포스트오더가 주어진다. 출력첫째 줄에 프리오더를 출력한다. 풀이중위순회의 정보는 노드들간의 좌우관계를 알려준다.후위순회에서의 마지막원소는 항상 루트노드의 값이다.즉, 루트노드를 중위순회..
https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/description/leetcode - Find the Number of Distinct Colors Among the Balls문제 유형: 해시문제 난이도: Medium 문제You are given an integer limit and a 2D array queries of size n x 2.There are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the ..