해커랭크(HackerRank)
-
Migratory Birds해커랭크(HackerRank) 2018. 8. 19. 17:36
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 1234567891011121314151617181920212223242526272829303132333435#include using namespace std; int migratoryBirds(int n, vector ar) { // Complete this function int brr[6] = {0,}; const int size = ar.size(); for(int i = 0; i ar[ar_i]; } int result = migratoryBirds(n, ar); cout
-
Bon Appétit해커랭크(HackerRank) 2018. 8. 19. 17:35
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;int main() { /* Enter your code here. Read inpu..
-
Cats and a Mouse해커랭크(HackerRank) 2018. 8. 19. 17:33
1. 문제 2. 알고리즘키워드 - 구현, 그리디 * 문제 풀이 - 두마리의 고양이가 쥐에게 접근하는 거리가 같다면 쥐는 도망 갈 수 있다. - 두마리의 고양이가 쥐에게 접근하는 거리가 다르다면 짧은 거리로 이동하는 고양이가 승리 한다. 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788#include using namespace std; vector split_string(string); /* * Complete the catAndMouse func..
-
Picking Numbers해커랭크(HackerRank) 2018. 8. 19. 17:32
1. 문제 2. 알고리즘키워드 - 구현 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940#include using namespace std; int pickingNumbers(vector a) { // Complete this function sort(a.begin(), a.end()); const int size = a.size(); int solution = 0; for(int i=0; i a[a_i]; } int result = pickingNumbers(a); cout
-
Designer PDF Viewer해커랭크(HackerRank) 2018. 8. 19. 17:31
1. 문제 입력으로 들어오는 int 배열은 각각의 글자의 높이 정보를 갖고 있다.높이 : 1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7글자 : a b c d e f g h i j k l m n o p q r s t u v w x y z abc 라는 글자가 있다면 각 글자의 높이는 아래와 같다.a = 1b = 3c = 1 높이가 가장 큰 글자 기준으로 highlight 사각형을 그려야 하기 때문에 답 = 글자 수 * 가장 큰 글자 height답 = 3 * 3답 = 9 2. 알고리즘키워드 - 구현 3. 코드 123456789101112131415161718192021222324252627282930#include using namespace std; int de..
-
Utopian Tree해커랭크(HackerRank) 2018. 8. 19. 17:30
1. 문제봄에는 2배로 커지고 여름에는 1씩 증가 된다. 2. 알고리즘키워드 - 구현 3. 코드 12345678910111213141516171819202122232425262728293031#include using namespace std; int utopianTree(int n) { // Complete this function int sol = 1; for(int i =1; i> t; for(int a0 = 0; a0 > n; int result = utopianTree(n); cout
-
Beautiful Days at the Movies해커랭크(HackerRank) 2018. 8. 19. 17:29
1. 문제 2. 알고리즘키워드 - 구현 * 문제 풀이입력 받은 두 수의 합의 차이의 절대 갑이 k 로 나누어 지는 횟수를 출력 하라 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940#include using namespace std; int reverse(int count) { int cand = count; int sol = 0; while(cand != 0) { int number = cand % 10; sol = sol * 10 + number; cand = cand / 10; } return sol;} int beautifulDays(int i, int j, int k) { // Complete this fu..