본문 바로가기

개발/코딩29

해커랭크(HackerRank) - Closest Numbers / C++ 문제 : 해커랭크 Closet Number https://www.hackerrank.com/challenges/closest-numbers/problem Closest Numbers | HackerRank Find the closest numbers in a list. www.hackerrank.com 언어 : C++ // Complete the closestNumbers function below. vector closestNumbers(vector arr) { set sorted; map diffmap; for(int i = 0 ;isecond; } 2020. 7. 11.
해커랭크(HackerRank) - The Full Counting Sort / C++ 문제: 해커랭크 - The Full Counting Sort 언어 : C++ 난이도: Midium https://www.hackerrank.com/challenges/countingsort4/problem?h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen The Full Counting Sort | HackerRank The real counting sort. www.hackerrank.com // Complete the countSort function below. void countSort(vector arr) { map strmap; int half = arr.size()/2; for(int i = 0 ; i< arr.size() ;i++) { strm.. 2020. 7. 11.
해커랭크(HackerRank) - Counting Sort 1,2 / C++ 문제: 해커랭크 - Counting Sort 1,2 www.hackerrank.com/challenges/countingsort1/problem Counting Sort 1 | HackerRank Count the number of times each value appears. www.hackerrank.com 언어 : C++ Counter Sort 1 // Complete the countingSort function below. vector countingSort(vector arr) { vector counter(100); for(int i = 0 ;i 2020. 7. 11.
해커랭크(HackerRank) - Running Time of Algorithms / C++ 문제 : 해커랭크 Running Time of Algorithms www.hackerrank.com/challenges/runningtime/problem?h_r=next-challenge&h_v=zen Running Time of Algorithms | HackerRank The running time of Algorithms in general and Insertion Sort in particular. www.hackerrank.com 난이도 : easy // Complete the runningTime function below. int runningTime(vector arr) { int shfitCout = 0; for(int i = 1 ; i= 0 && arr[j]>value) { arr[j.. 2020. 7. 11.
재귀(Recusion) 알고리즘 사용 예 재귀(Recusion) 알고리즘 재귀 함수는 자기 자신을 참조하는 함수입니다. 원래의 문제를 동일한 유형의 하위 문제로 나누고 하위문제를 해결한 다음 결과와 결합합니다. 이러한 알고리즘을 분할 정복법 이라 합니다. 또 하위 결과를 저장하여 조회하는 알고리즘이 추가되면 동적프로그래밍이라고 부릅니다. 이러한 재귀함수 다음과 같은 구조를 가져야 합니다. Base Case : 재귀함수의 종료 조건으로 더 이상 문제를 쪼갤수 없을 때, 자기자신을 호출하지 않고 답이 나올 때 Recusion Case: 복잡한 입력을 더 간단한 입력으로 분류하여 자기자신을 호출 재귀의 활용 예시 다음은 재귀 함수의 활용 예시 입니다. factorial (계수) 구하기 다음 factorial 함수는 n! 을 구합니다. int fact.. 2020. 7. 10.
해커랭크(HackerRank) - Strong Password / C++ 문제 : 해커랭크 - Strong Password 난이도 : easy 언어 : C++ https://www.hackerrank.com/challenges/strong-password/problem Strong Password | HackerRank How many characters should you add to make the password strong? www.hackerrank.com // Complete the minimumNumber function below. int minimumNumber(int n, string password) { // Return the minimum number of characters to make the password strong string numbers .. 2020. 6. 30.
해커랭크(HackerRank) - CamelCase / C++ 문제 : CamelCase 해커랭크 https://www.hackerrank.com/challenges/camelcase/problem CamelCase | HackerRank www.hackerrank.com 언어 : C++ 난이도: easy // Complete the camelcase function below. int camelcase(string s) { int wordCount = 1; for (int i = 0; i = 'A' && s.at(i) 2020. 6. 30.
해커랭크(HackerRank) - Drawing Book / C++ 문제 : 해커랭크 Drawing Book https://www.hackerrank.com/challenges/drawing-book/problem 언어 : C++ 난이도: Easy /* * Complete the pageCount function below. */ int pageCount(int n, int p) { /* * Write your code here. */ int f = 0; int f2 = 0; int b = 0; for (int i = 0; i f2) return f2; return f; } 2020. 6. 30.
해커랭크(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.