본문 바로가기

해커랭크22

해커랭크(HackerRank) - Almost Sorted // C++ https://www.hackerrank.com/challenges/almost-sorted/problem Almost Sorted | HackerRank Sort an array by either swapping or reversing a segment www.hackerrank.com void segmentSort(vector* arr, int from, int to) { sort(arr->begin()+from, arr->begin()+to+1); } bool isASC(vector arr, int from, int to) { int prev = arr[from]; for(int i = from+1; i arr[i]) { return false; } prev = arr[i]; } return tru.. 2021. 5. 19.
해커랭크(HackerRank) - The Grid Search // C++ 해커랭크(HackerRank) - The Grid Search // C++ https://www.hackerrank.com/challenges/the-grid-search/problem string gridSearch(vector G, vector P) { int gridRow = G.size(); int gridCol = G[0].length(); int patternRow = P.size(); int patternCol = P[0].length(); for(int j = 0 ;j 2021. 5. 16.
해커랭크(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.
해커랭크(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.