목록PS/LeetCode (591)
넘치게 채우기
https://leetcode.com/problems/water-bottles/description/leetcode - water bottles문제 유형 : 구현, 그리디문제 난이도 : Easy 문제There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.The operation of drinking a full water bottle turns it into an empty bottle.Given the two integers numBottles and numExchange,..
https://leetcode.com/problems/pass-the-pillow/description/leetcode - Pass the Pillow문제 유형 : 수학, 구현문제 난이도 : Easy 문제There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, an..
https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/description/leetcode - Find the Minimum and Maximum Number of Nodes Between Critical Points문제 유형 : 연결리스트, 슬라이딩 윈도우문제 난이도 : Medium 문제A critical point in a linked list is defined as either a local maxima or a local minima.A node is a local maxima if the current node has a value strictly greater than ..

https://leetcode.com/problems/merge-nodes-in-between-zeros/description/leetcode - Merge Nodes in Between Zeros문제 유형 : 연결리스트, 투 포인터문제 난이도 : Medium 문제You are given the head of a linked list, which contains a series of integers separated by 0's. The beginning and end of the linked list will have Node.val == 0.For every two consecutive 0's, merge all the nodes lying in between them into a single nod..
https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/description/leetcode - Minimum Difference Between Largest and Smallest Value in Three Moves문제 유형 : 그리디, 정렬, 슬라이딩 윈도우문제 난이도 : Medium 문제You are given an integer array nums.In one move, you can choose one element of nums and change it to any value.Return the minimum difference between the largest and ..
https://leetcode.com/problems/intersection-of-two-arrays-ii/description/leetcode - Intersection of Two Arrays II문제 유형 : 그리디, 정렬문제 난이도 : Easy 문제Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order. 두 정수 nums1과 nums2가 주어진다. 두 배열의 합집합을 구하시오.요소는 여러 번 ..
https://leetcode.com/problems/three-consecutive-odds/description/leetcode - Three Consecutive Odds문제 유형 : 그리디, 배열문제 난이도 : Easy 문제Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.정수 배열 arr이 주어진다.홀수 3개가 붙어있으면 true를 반환하라.아니면 false를 반환하라. 풀이streak변수를 만들어서 몇 개 째 붙어 있는지 확인한다.3번붙은적있다면 True를, 그런일없이 배열을 순회하면 false를 반환한다. 코드C++#pragma..
https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/description/leetcode - Remove Max Number of Edes to Keep Graph Fully Traversable문제 유형 : 유니온-파인드, 그리디문제 난이도 : Hard 문제Alice and Bob have an undirected graph of n nodes and three types of edges:Type 1: Can be traversed by Alice only.Type 2: Can be traversed by Bob only.Type 3: Can be traversed by both Alice and..
https://leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/description/leetcode - All Ancestros of a Node in a Directed Acyclic Graph문제 유형 : 위상 정렬문제 난이도 : Medium 문제You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusive).You are also given a 2D integer array edges, where edges[..
https://leetcode.com/problems/maximum-total-importance-of-roads/description/leetcode - Maximum Total Importance of Roads문제 유형 : 그리디, 우선순위 큐, 그래프문제 난이도 : Medium 문제You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1.You are also given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecti..