DINGA DINGA
article thumbnail
[HackerRank] Sparse Arrays
C & C++/HackerRank 2021. 7. 29. 16:53

https://www.hackerrank.com/challenges/sparse-arrays/problem Sparse Arrays | HackerRank Determine the number of times a string has previously appeared. www.hackerrank.com Data Structures > Arrays strings 배열과 queries 배열이 주어지면, queries 배열의 각 원소가 strings 배열에 몇 개 있는지를 카운트해 배열 형태로 리턴한다. 코드 int* matchingStrings(int strings_count, char** strings, int queries_count, char** queries, int* result_count) { *..

article thumbnail
[HackerRank] Electronics Shop
C & C++/HackerRank 2021. 7. 29. 16:23

https://www.hackerrank.com/challenges/electronics-shop/problem Electronics Shop | HackerRank Determine the most expensive Keyboard and USB drive combination one can purchase within her budget. www.hackerrank.com Algorithms > Implementation 주어진 예산으로 살 수 있는 가장 비싼 조합(키보드+드라이브)의 가격을 리턴한다. 가능한 조합이 없으면 -1을 리턴한다. 코드 int getMoneySpent(int keyboards_count, int* keyboards, int drives_count, int* drives, i..

article thumbnail
[HackerRank] Arrays - DS
C & C++/HackerRank 2021. 7. 21. 15:11

https://www.hackerrank.com/challenges/arrays-ds/problem Arrays - DS | HackerRank Accessing and using arrays. www.hackerrank.com Data Structures > Arrays 배열이 주어지면 순서를 반전시켜 리턴한다. 코드 int* reverseArray(int a_count, int* a, int* result_count) { *result_count = a_count; int left = 0, right = a_count - 1, temp; for (int i = 0; i < a_count / 2; i++){ temp = a[left]; a[left] = a[right]; a[right] = temp; ..

article thumbnail
[HackerRank] CamelCase
C & C++/HackerRank 2021. 7. 21. 12:37

https://www.hackerrank.com/challenges/camelcase/problem CamelCase | HackerRank www.hackerrank.com Algorithms > Strings 문자열이 주어지면 해당 문자열이 포함하는 단어의 개수를 리턴한다. 코드 int camelcase(char* s) { int cnt = 1; for (int i = 0; i = 'A' && s[i]

728x90