알고리즘/알고리즘 문제풀이
-
#include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'flippingMatrix' function below. * * The function is expected to return an INTEGER. * The function accepts 2D_INTEGER_ARRAY matrix as parameter. */ int flippingMatrix(vector matrix) { int n = matrix.size() / 2; int max_sum = 0; for (int i = 0; i < n; i++) { fo..
[HackerRank] Flipping the Matrix#include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'flippingMatrix' function below. * * The function is expected to return an INTEGER. * The function accepts 2D_INTEGER_ARRAY matrix as parameter. */ int flippingMatrix(vector matrix) { int n = matrix.size() / 2; int max_sum = 0; for (int i = 0; i < n; i++) { fo..
2023.10.19 -
https://www.hackerrank.com/challenges/one-week-preparation-kit-countingsort1 Counting Sort 1 | HackerRank Count the number of times each value appears. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'countingSort' function below. * * The function is expected to return an INTEGER_ARRAY. *..
[HackerRank] Counting Sort 1https://www.hackerrank.com/challenges/one-week-preparation-kit-countingsort1 Counting Sort 1 | HackerRank Count the number of times each value appears. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'countingSort' function below. * * The function is expected to return an INTEGER_ARRAY. *..
2023.10.19 -
https://www.hackerrank.com/challenges/one-week-preparation-kit-diagonal-difference Diagonal Difference | HackerRank Calculate the absolute difference of sums across the two diagonals of a square matrix. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'diagonalDifference' function below. *..
[HackerRank] Diagonal Differencehttps://www.hackerrank.com/challenges/one-week-preparation-kit-diagonal-difference Diagonal Difference | HackerRank Calculate the absolute difference of sums across the two diagonals of a square matrix. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'diagonalDifference' function below. *..
2023.10.19 -
https://www.hackerrank.com/challenges/one-week-preparation-kit-lonely-integer Lonely Integer | HackerRank Find the unique element in an array of integer pairs. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'lonelyinteger' function below. * * The function is expected to return an INTEGER..
[HackerRank] Lonely Integerhttps://www.hackerrank.com/challenges/one-week-preparation-kit-lonely-integer Lonely Integer | HackerRank Find the unique element in an array of integer pairs. www.hackerrank.com #include using namespace std; string ltrim(const string &); string rtrim(const string &); vector split(const string &); /* * Complete the 'lonelyinteger' function below. * * The function is expected to return an INTEGER..
2023.10.19 -
int findMedian(vector arr) { sort(arr.begin(), arr.end()); int n = arr.size(); int median = arr[n / 2]; return median; }
[HackerRank] Find Medianint findMedian(vector arr) { sort(arr.begin(), arr.end()); int n = arr.size(); int median = arr[n / 2]; return median; }
2023.10.19 -
void fizzBuzz(int n) { for (int i = 1; i
[HackerRank] FizzBuzzvoid fizzBuzz(int n) { for (int i = 1; i
2023.10.19