DINGA DINGA
article thumbnail
[HackerRank] Counting Sort 2
C & C++/HackerRank 2021. 10. 9. 17:48

https://www.hackerrank.com/challenges/countingsort2/problem Counting Sort 2 | HackerRank Simple version of counting sort. www.hackerrank.com Algorithms > Sorting 정수 리스트가 주어지면 각 값이 등장하는 횟수를 세어 배열에 저장하고, 0이 아닌 각 인덱스의 값을 횟수만큼 출력한다. 코드 int* countingSort(int arr_count, int* arr, int* result_count) { *result_count = arr_count; int *count = malloc(100 * sizeof(int)); int *res = malloc(arr_count * sizeo..

article thumbnail
[Challenge(Old)] old-55 (40)
WEB/Webhacking.kr 2021. 10. 9. 17:28

https://webhacking.kr/challenge/web-31/ https://webhacking.kr/challenge/web-31/ webhacking.kr 메인 페이지다. 마우스를 움직이면 마우스 포인터를 따라 캐릭터가 움직이고, 점수와 x좌표, y좌표로 추측되는 숫자들이 바뀐다. rank를 눌러보았다. 랭킹이 뜨고, 맨 아래에 쿼리가 있다. mysqli_query($db,"insert into chall55 values('{$_SESSION['id']}','".trim($_POST['score'])."','{$flag}')"); chall55 테이블에 id, score, flag가 차례로 저장되는 것을 알 수 있다. 점수를 눌러보니 맨 위에 아이디와 점수가 출력되었다. 쿼리의 score부분..

article thumbnail
[Challenge(Old)] old-53 (35)
WEB/Webhacking.kr 2021. 10. 9. 16:01

https://webhacking.kr/challenge/web-28/ Challenge 53 webhacking.kr 소스코드를 살펴보았다.

article thumbnail
[HackerRank] Diagonal Difference
C & C++/HackerRank 2021. 10. 2. 14:59

https://www.hackerrank.com/challenges/diagonal-difference/problem Diagonal Difference | HackerRank Calculate the absolute difference of sums across the two diagonals of a square matrix. www.hackerrank.com Algorithms > Warmup 2차원 배열이 주어지면 왼쪽 대각선과 오른쪽 대각선의 합을 각각 구해서 그 차의 절댓값을 리턴한다. 코드 int diagonalDifference(int arr_rows, int arr_columns, int** arr) { int left = 0, right = 0; for (int i = 0, j = ar..

728x90