본문 바로가기

해커랭크22

해커랭크(HackerRank) - Climbing the Leaderboard / C++ 문제 : 해커랭크 - Climbing the Leaderboard 난이도: midium 언어 : C++ https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem Climbing the Leaderboard | HackerRank Help Alice track her progress toward the top of the leaderboard! www.hackerrank.com // Complete the climbingLeaderboard function below. vector climbingLeaderboard(vector scores, vector alice) { vector aliceRank ; set scoreSet; for(.. 2020. 6. 29.
해커랭크(HackerRank) - Bon Appétit / C++ 문제 : 해커랭크 - Bon Appétit https://www.hackerrank.com/challenges/bon-appetit/problem Bon Appétit | HackerRank Determine whether or not Brian overcharged Anna for their split bill. www.hackerrank.com 난이도: Easy 언어 : C++ // Complete the bonAppetit function below. void bonAppetit(vector bill, int k, int b) { int annaToChargeSum = 0; int toRefund = 0; for(int i = 0 ;i 2020. 6. 26.
해커랭크(HackerRank) - Insert a node at the head of a linked list / C++ 문제 : 해커랭크 - Insert a node at the head of a linked list 난이도: Easy 언어 : C++ SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* ret ; if(llist == nullptr) { llist = new SinglyLinkedListNode(data); ret = llist; }else { SinglyLinkedListNode* nNode = new SinglyLinkedListNode(data); nNode->next = llist; ret = nNode; } return ret; } 2020. 2. 13.
해커랭크(HackerRank) - Insert a Node at the Tail of a Linked List / C++ 문제 : 해커랭크 - Insert a Node at the Tail of a Linked List 난이도: Easy 언어 : C++ SinglyLinkedListNode* insertNodeAtTail(SinglyLinkedListNode* head, int data) { if(head == nullptr ) { head = new SinglyLinkedListNode(data); } else { SinglyLinkedListNode* node = head; while(node->next!= nullptr ) { node= node->next; } node->next = new SinglyLinkedListNode(data); } return head; } 2020. 2. 13.
해커랭크(HackerRank) - Left Rotation / C++ 문제 : 해커랭크 -Left Rotation 난이도: Easy 언어 : C++ int main() { string nd_temp; getline(cin, nd_temp); vector nd = split_string(nd_temp); int n = stoi(nd[0]); int d = stoi(nd[1]); string a_temp_temp; getline(cin, a_temp_temp); vector a_temp = split_string(a_temp_temp); vector a(n); vector r(n); for (int i = 0; i < n; i++) { int a_item = stoi(a_temp[i]); a[i] = a_item; int idx = (n-d +i)%n; r[idx] = a[i.. 2020. 2. 11.
해커랭크(HackerRank) - 2D Array - DS / C++ 문제 : 해커랭크 - 2D Array - DS 난이도: Easy 언어 : C++ int hourglassSum(vector arr) { set sum; for(int i = 0;i 2020. 2. 11.
해커랭크(HackerRank) - Weighted Uniform Strings / C++ 문제 : 해커랭크 - Weighted Uniform Strings 난이도: Easy 언어 : C+ // Complete the weightedUniformStrings function below. vector weightedUniformStrings(string s, vector queries) { vector result; map weight; char prev = 0; int prevWeight = 0; for(int i = 0 ;i 2020. 2. 6.
해커랭크(HackerRank) - Day of the Programmer / C++ 문제 : 해커랭크 - Migratory BirdsDay of the Programmer 난이도: Easy 언어 : C++ // Complete the dayOfProgrammer function below. string dayOfProgrammer(int year) { string day; if(year == 1918) return day="26.09."+ to_string (year); if ((year < 1918 && year % 4 == 0) || (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { day="12.09."+ to_string (year); }else { day="13.09."+ to_string (year); } return day.. 2020. 2. 5.
해커랭크(HackerRank) - Migratory Birds / C++ 문제 : 해커랭크 - Migratory Birds 난이도: Easy 언어 : C++ // Complete the migratoryBirds function below. int migratoryBirds(vector arr) { int type[6] = {0,}; for(int i = 0 ;i 2020. 2. 4.