목록PS (854)
넘치게 채우기
https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/description/leetcode - Check If a Word Occurs As a Prefix of Any Word in a Sentence문제 유형: 문자열 처리문제 난이도: Easy 문제Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.Return the index of the word in sentence (1-inde..
https://www.acmicpc.net/problem/1058BOJ - 친구문제 유형: bfs문제 난이도: Silver II시간 제한: 2초메모리 제한: 128MB 문제지민이는 세계에서 가장 유명한 사람이 누구인지 궁금해졌다. 가장 유명한 사람을 구하는 방법은 각 사람의 2-친구를 구하면 된다. 어떤 사람 A가 또다른 사람 B의 2-친구가 되기 위해선, 두 사람이 친구이거나, A와 친구이고, B와 친구인 C가 존재해야 된다. 여기서 가장 유명한 사람은 2-친구의 수가 가장 많은 사람이다. 가장 유명한 사람의 2-친구의 수를 출력하는 프로그램을 작성하시오.A와 B가 친구면, B와 A도 친구이고, A와 A는 친구가 아니다. 입력첫째 줄에 사람의 수 N이 주어진다. N은 50보다 작거나 같은 자연수이다. ..
https://leetcode.com/problems/check-if-n-and-its-double-exist/description/leetcode - Check If N and Its Double Exist문제 유형: 투 포인터문제 난이도: Easy 문제Given an array arr of integers, check if there exist two indices i and j such that :i != j0 arr[i] == 2 * arr[j]서로 다른 두 인덱스 i, j에 대해서arr[i] == arr[j] *2가 있으면 true를 반환하시오. 풀이2중for문을 돌면서 서로 다른인덱스이고 2배관계인 쌍이있으면 true를, 아니면 false를 반환해준다.단, 다른인덱스임을 고려를 반드시 해줘야하..
https://leetcode.com/problems/valid-arrangement-of-pairs/description/leetcode - Valid Arrangement of Pairs문제 유형: 그래프, 오일러 경로, 오일러 회로, dfs문제 난이도: Hard 문제You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 endi-1 == starti.Return any valid arrangement of pairs.Note: The inputs will be generated such that t..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/rFRKv/btsK1SpSm5V/aKbWV6wk6kaVHykxYHu7Dk/img.png)
https://www.acmicpc.net/problem/1024BOJ - 수열의 합문제 유형: 수학, 그리디문제 난이도: Silver II시간 제한: 2초메모리 제한: 128MB 문제N과 L이 주어질 때, 합이 N이면서, 길이가 적어도 L인 가장 짧은 연속된 음이 아닌 정수 리스트를 구하는 프로그램을 작성하시오. 입력첫째 줄에 N과 L이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이고, L은 2보다 크거나 같고, 100보다 작거나 같은 자연수이다. 출력만약 리스트의 길이가 100보다 작거나 같으면, 연속된 수를 첫째 줄에 공백으로 구분하여 출력한다. 만약 길이가 100보다 크거나 그러한 수열이 없을 때는 -1을 출력한다. 풀이 l개의 길이의 가장 작은 수를 x라 하자.x부터 순차적으..
https://leetcode.com/problems/minimum-time-to-visit-a-cell-in-a-grid/description/leetcode - Minimum Time to Visit a Cell in a Grid문제 유형: 최단 경로, 행렬, 그래프문제 난이도: Hard 문제You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) only when the tim..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/smYcA/btsKY1GIJCP/RW9IuAGOIde1q5jhfmCCyk/img.png)
https://www.acmicpc.net/problem/1918BOJ - 후위 표기식문제 유형: 스택, 문자열 처리, 트리문제 난이도: Gold II시간 제한: 2초메모리 제한: 128MB 문제수식은 일반적으로 3가지 표기법으로 표현할 수 있다. 연산자가 피연산자 가운데 위치하는 중위 표기법(일반적으로 우리가 쓰는 방법이다), 연산자가 피연산자 앞에 위치하는 전위 표기법(prefix notation), 연산자가 피연산자 뒤에 위치하는 후위 표기법(postfix notation)이 그것이다. 예를 들어 중위 표기법으로 표현된 a+b는 전위 표기법으로는 +ab이고, 후위 표기법으로는 ab+가 된다.이 문제에서 우리가 다룰 표기법은 후위 표기법이다. 후위 표기법은 위에서 말한 법과 같이 연산자가 피연산자 뒤..
https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/description/leetcode - Minimum Obstacle Removal to Reach Corner문제 유형: 최단경로, 다익스트라, 다이나믹 프로그래밍문제 난이도: Hard 문제You are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values:0 represents an empty cell,1 represents an obstacle that may be removed.You can move up, down, left, or right from and to an..
https://www.acmicpc.net/problem/1167BOJ - 트리의 지름문제 유형: 최단 거리, 다익스트라, 트리, 그래프, 트리의 지름문제 난이도: Gold II시간 제한: 2초메모리 제한: 512MB 문제트리의 지름이란, 트리에서 임의의 두 점 사이의 거리 중 가장 긴 것을 말한다. 트리의 지름을 구하는 프로그램을 작성하시오. 입력트리가 입력으로 주어진다. 먼저 첫 번째 줄에서는 트리의 정점의 개수 V가 주어지고 (2 ≤ V ≤ 100,000)둘째 줄부터 V개의 줄에 걸쳐 간선의 정보가 다음과 같이 주어진다. 정점 번호는 1부터 V까지 매겨져 있다.먼저 정점 번호가 주어지고, 이어서 연결된 간선의 정보를 의미하는 정수가 두 개씩 주어지는데, 하나는 정점번호, 다른 하나는 그 정점까지의 ..
https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/description/leetcode - Shortest Distance After Road Addition Queries I문제 유형: 최단 경로, 그래프, 다익스트라, 다이나믹 프로그래밍문제 난이도: Medium 문제You are given an integer n and a 2D integer array queries.There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 queries[i] = [ui..