목록그리디 (88)
넘치게 채우기
https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/description/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 유형 : 그리디, 배열 문제 난이도 : Medium 문제 There are n pieces arranged in a line,..
https://school.programmers.co.kr/learn/courses/30/lessons/150369?language=cpp 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 유형 : 스택, 구현, 그리디 문제 난이도: Level 2 문제 설명 당신은 일렬로 나열된 n개의 집에 택배를 배달하려 합니다. 배달할 물건은 모두 크기가 같은 재활용 택배 상자에 담아 배달하며, 배달을 다니면서 빈 재활용 택배 상자들을 수거하려 합니다. 배달할 택배들은 모두 재활용 택배 상자에 담겨서 물류창고에 보관되어 있고, i번째 집은 물류창고에서 거리 i만큼 ..
https://leetcode.com/problems/integer-to-roman/description/?envType=study-plan-v2&envId=top-interview-150 Integer to Roman - LeetCode Can you solve this real interview question? Integer to Roman - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.c..
https://leetcode.com/problems/candy/description/?envType=study-plan-v2&envId=top-interview-150 Candy - LeetCode Can you solve this real interview question? Candy - There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: * Each leetcode.com 문제 유형 : 그리디 문제 난이..
https://school.programmers.co.kr/learn/courses/30/lessons/42883 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 유형 : 그리디 문제 난이도 : Level 2 문제 어떤 숫자에서 k개의 수를 제거했을 때 얻을 수 있는 가장 큰 숫자를 구하려 합니다. 예를 들어, 숫자 1924에서 수 두 개를 제거하면 [19, 12, 14, 92, 94, 24] 를 만들 수 있습니다. 이 중 가장 큰 숫자는 94 입니다. 문자열 형식으로 숫자 number와 제거할 수의 개수 k가 solution 함수의 매개변수로 주어집..
https://leetcode.com/problems/dota2-senate/description/ Dota2 Senate - LeetCode Can you solve this real interview question? Dota2 Senate - In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the Senate wants to decide on a change in the Dota2 game. leetcode.com 문제 유형 : 그리디 / 큐 / 구현 문제 난이도 : Medium 문제 In the wo..
https://leetcode.com/problems/gas-station/description/ Gas Station - LeetCode Can you solve this real interview question? Gas Station - There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith st leetcode.com 문제 유형 : 그리디 / 브루트 포스 난이도 : Medium 문제 There are n g..
"당장 최선의 수를 고려하기" 탐욕 알고리즘은 매 선택마다 당장의 최선의 선택을 하여 답에 도달하는 방법이다. 항상 최선의 결과를 보여주지는 않지만 특정 상황들 속에서는 굉장히 효과적이고, 직관적이다. 대표적인 예시로는, 거스름돈이 있다. #include #include using namespace std; int input; int wons[4] = {500, 100, 50, 10}; vector calc_coin(int money) { vector coins = vector(4); coins[0] = money / 500; coins[1] = (money % 500) / 100; coins[2] = (money % 100) / 50; coins[3] = (money % 50) / 10; return ..