2D Array - DS Context Given a 2D Array, :1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation:a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass' values.Task Calculate the hourglass sum for every hourglass in , then print the maximum ho.. 더보기 Arrays - DS An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), that can be referenced as (you may also see it written as ).Given an array, , of integers, print each element in reverse order as a single line of space-separated integers.Note: If you've already solved our C++ .. 더보기 Sorting: Bubble Sort Consider the following version of Bubble Sort:for (int i = 0; i a[j+1]){ int tmp = a[j+1]; a[j+1] = a[j]; a[j] = tmp; count++; } } } System.out.println("Array is sorted in " + count + " swaps."); System.out.println("First Element: " + a[0]); System.out.println("Last Element: " + a[a.length-1]); } } 더보기 Heaps: Find the Running Median The median of a dataset of integers is the midpoint value of the dataset for which an equal number of integers are less than and greater than the value. To find the median, you must first sort your dataset of integers in non-decreasing order, then:If your dataset contains an odd number of elements, the median is the middle element of the sorted sample. In the sorted dataset , is the median.If yo.. 더보기 Level 4- 땅따먹기 게임 영희는 땅따먹기 게임에 푹 빠졌습니다. 땅따먹기 게임의 땅은 총 N행 4열로 나누어져 있고, 모든 칸에는 점수가 쓰여 있습니다. 땅을 밟으면서 한 행씩 내려올 때, 영희는 각 행의 4칸 중 1칸만 밟으면서 내려올 수 있습니다. 땅따먹기 게임에는 같은 열을 연속해서 밟을 수가 없는 특수 규칙이 있습니다. 즉, 1행에서 (5)를 밟았다면, 2행의 (8)은 밟을 수가 없게 됩니다. 마지막 행까지 모두 내려왔을 때, 점수가 가장 높은 사람이 게임의 승자가 됩니다. 여러분이 hopscotch 함수를 제작하여 영희가 최대 몇 점을 얻을 수 있는지 알려주세요. 예를 들어 1 2 3 5 5 6 7 8 4 3 2 1 의 땅이 있다면, 영희는 각 줄에서 (5), (7), (4) 땅을 밟아 16점을 최고점으로 받을 수 있으.. 더보기 Regular Expression: 정규표현식 3 참고 사이트: http://zvon.org/comp/r/tut-Regexp.html#Pages~Contents 풀이: 일부 characters 들의 경우 특별한 의미를 가지고 있다고 한다. 문자 앞에 ^ 가 붙으면 가장 앞에 해당 단어를 나타냄(ex: ^who 면 who 중에서 가장 앞에 있는 who를 match 함) 문자뒤에 $ 달러표시가 있으면 가장 뒤에 있는 해당 단어를 나타냄(ex: who$면 who중에서 가장 뒤에 있는 who를 match 함) 더보기 Regular Expression: 정규표현식 2 참고 사이트: http://zvon.org/comp/r/tut-Regexp.html#Pages~Contents 각각의 character는 스페이스(띄어쓰기)나 탭, 그리고 새로운 줄 에도 영향을 받는다. case1의 경우 Hellow, world 간의 간격이 스페이스 하나인데 case2에서 스페이스가 2개 로 벌어지자 어느것도 match가 되지 않는다. 더보기 Regular Expression: 정규표현식 1 참고 사이트: http://zvon.org/comp/r/tut-Regexp.html#Pages~Contents 기술면접에서 나온건 아니지만 코딩테스트에서 정규식에 관련해서 묻는 문제가 있어서 한번 정리해보려고 한다. 위의 참고 사이트를 보면서 정리를 했고 간단하게 설명해보고자 한다. First match: 정규식 표현을 입력했을 때 가장 처음에 match 된 부분을 보여줌All matches: match된 모든 부분을 다 보여줌 대소문자를 구분해서 match가 되는 걸 알 수 있다. 더보기 Is This a Binary Search Tree? (Java) Write a function that takes a binary tree and returns true if it is a binary search tree, and false if not.In our test code, we're going to use the following examples:head1 = 0 / \ 1 2 /\ /\ 3 4 5 6head1 is NOT a binary search tree.head2 = 3 / \ 1 4 /\ / \ 0 2 5 6head2 is NOT a binary search tree.head3 = 3 / \ 1 5 /\ / \ 0 2 4 6head3 is a binary search tree.head4 = 3 / \ 1 5 /\ 0 4head4 is NOT a.. 더보기 N-th Element of a Linked List (Java) Implement a function that finds the nth node in a linked list, counting from the end.Your function should take a linked list (its head element) and n, a positive integer as its arguments.Examples:head = 7 -> 6 -> 5 -> 4 -> 3 -> 2 -> 1 -> (null / None)The third element of head counting from the end is 3.head2 = 1 -> 2 -> 3 -> 4 -> (null / None)The fourth element of head2 counting from the end is .. 더보기 이전 1 ··· 3 4 5 6 7 8 9 ··· 16 다음