본문 바로가기

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: 정규표현식 2 참고 사이트: http://zvon.org/comp/r/tut-Regexp.html#Pages~Contents 각각의 character는 스페이스(띄어쓰기)나 탭, 그리고 새로운 줄 에도 영향을 받는다. case1의 경우 Hellow, world 간의 간격이 스페이스 하나인데 case2에서 스페이스가 2개 로 벌어지자 어느것도 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 .. 더보기
Rotating a 2D Array by 90 Degrees - In Place (Java) A 2-dimensional array is an array of arrays.Implement a function that takes a square 2D array (# columns = # rows) and rotates it by 90 degrees.Example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]->[[7, 4, 1], [8, 5, 2], [9, 6, 3]]When you are done, try implementing this function so that you can solve this problem in place. Solving it in place means that your function won't create a new array to solve thi.. 더보기
Rotating a 2D Array by 90 Degrees (Java) A 2-dimensional array is an array of arrays.Implement a function that takes a square 2D array (# columns = # rows) and rotates it by 90 degrees.Example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]->[[7, 4, 1], [8, 5, 2], [9, 6, 3]]When you are done, try implementing this function so that you can solve this problem in place. Solving it in place means that your function won't create a new array to solve thi.. 더보기
Find Where to Expand in Minesweeper (Java) Implement a function that turns revealed cells into -2 given a location the user wants to click.For simplicity, only reveal cells that have 0 in them. If the user clicks on any other type of cell (for example, -1 / bomb or 1, 2, or 3), just ignore the click and return the original field. If a user clicks 0, reveal all other 0's that are connected to it.Example 1: Given field: [[0, 0, 0, 0, 0], [.. 더보기
Assign Numbers in Minesweeper (Java) Implement a function that assigns correct numbers in a field of Minesweeper, which is represented as a 2 dimensional array.Example: The size of the field is 3x4, and there are bombs at the positions [0, 0] (row index = 0, column index = 0) and [0, 1] (row index = 0, column index = 1).Then, the resulting field should be:[[-1, -1, 1, 0], [2, 2, 1, 0], [0, 0, 0, 0]] Your function should return the .. 더보기
One Away Strings (Java) Write a function that takes two strings and returns true if they are one away from each other.They are one away from each other if a single operation (changing a character, deleting a character or adding a character) will change one of the strings to the other.Examples:"abcde" and "abcd" are one away (deleting a character)."a" and "a" are one away (changing the only character 'a' to the equivale.. 더보기
Day 29: Bitwise AND Task Given set . Find two integers, and (where ), from set such that the value of is the maximum possible and also less than a given integer, . In this case, represents the bitwise ANDoperator.Input FormatThe first line contains an integer, , the number of test cases. Each of the subsequent lines defines a test case as space-separated integers, and , respectively.ConstraintsOutput FormatFor each.. 더보기