알고리즘
-
정렬 > H-Index프로그래머스(Programmers) 2018. 9. 30. 18:49
https://programmers.co.kr/learn/courses/30/lessons/42747 1. 문제 3 0 6 1 5 -> 정렬을 한다. 6 5 3 1 0 step 1 - [6] 5 3 1 0 - h 1증가step 2 - 6 [5] 3 1 0 - h 1증가step 3 - 6 5 [3] 1 0 - h 1증가step 4 - 6 5 3 [1] 0 - h 3 이고 4 번째 원소가 1 임으로 증가하지 못 한다.step 5 - 6 5 3 1 [0] - h 3 이고 5 번째 원소가 0 임으로 증가하지 못 한다. 2. 알고리즘키워드 - 정렬 3. 코드 123456789101112131415#include #include #include #include using namespace std; int solut..
-
백준 5052번: 전화번호 목록구현(Implementation) 2018. 9. 30. 18:07
https://www.acmicpc.net/problem/5052 1. 문제 2. 알고리즘키워드 - 구현, 해시 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_SIZE 100#define INF 0x7fffffff#define CENDL "\n"#define l..
-
해시 > 전화번호 목록프로그래머스(Programmers) 2018. 9. 30. 18:01
https://programmers.co.kr/learn/courses/30/lessons/42577 1. 문제정렬하여 인접한 배열 원소를 만들어서 이전에 문자와 현재 문자사이에 이전 문자열이 원소로 있다면 접두사를 갖는다는 의미로 처리하는 문제. 119, 2121212, 1119114 와 같은 문자열 벡터가 있다면 정렬 후에는 119, 1119114, 2121212 형태로 정렬 된다. 2. 알고리즘키워드 - 해시, 정렬 3. 코드 123456789101112131415161718192021222324#include #include #include #include #include using namespace std;bool solution(vector phoneBook) { bool answer = tr..
-
스택/큐 > 다리를 지나는 트럭스택(Stack) 2018. 9. 29. 20:52
https://programmers.co.kr/learn/courses/30/lessons/42583 1. 문제 2. 알고리즘키워드 - 스택 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243#include #include #include using namespace std; int solution(int bridge_length, int weight, vector truck_weights) { queue q; int sum, count; sum = count = 0; for(int i=0; i weight) { q.push(0); count++; } else { q.push(d); count++; sum ..
-
백준 10799번: 쇠막대기스택(Stack) 2018. 9. 29. 19:19
https://www.acmicpc.net/problem/10799 1. 문제 2. 알고리즘키워드 - 스택 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_SIZE 100#define INF 0x7fffffff#define CENDL "\n"#define ll lon..
-
스택/큐 > 쇠막대기프로그래머스(Programmers) 2018. 9. 26. 21:23
https://programmers.co.kr/learn/courses/30/lessons/42585 1. 문제 2. 알고리즘키워드 - 스택 3. 코드 12345678910111213141516171819202122232425262728293031#include #include #include using namespace std; int solution(string arrangement) { int answer = 0; const int size = arrangement.size(); stack s; char before = 0; for (int i = 0; i
-
스택/큐 > 탑프로그래머스(Programmers) 2018. 9. 26. 21:22
https://programmers.co.kr/learn/courses/30/lessons/42588 1. 문제 2. 알고리즘키워드 - 큐 3. 코드 12345678910111213141516171819202122232425262728293031323334353637#include #include #include #include using namespace std; vector solution(vector heights) { vector answer; queue qq1; reverse(heights.begin(), heights.end()); int size = heights.size(); for (int i = 0; i
-
정렬 > 가장 큰 수프로그래머스(Programmers) 2018. 9. 20. 17:27
https://programmers.co.kr/learn/courses/30/lessons/42746 1. 문제 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 수는 6210입니다. 0 또는 양의 정수가 담긴 배열 numbers가 매개변수로 주어질 때, 순서를 재배치하여 만들 수 있는 가장 큰 수를 문자열로 바꾸어 return 하도록 solution 함수를 작성해주세요. - 제한 사항numbers의 길이는 1 이상 100,000 이하입니다.numbers의 원소는 0 이상 1,000 이하입니다.정답이 너무 클 ..