예를 들어 a = 3, b = 5인 경우, 3 + 4 + 5 = 12이므로 12를 리턴합니다. */
알고리즘이나 기타 생각할 것도 따로 없고 그냥 풀면 된다
단순히 더하기만 하면 되기때문에 입력크기가 커도 큰 문제 없는듯.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1와 0로 채워진 표(board)가 있습니다. 표 1칸은 1 x 1 의 정사각형으로 이루어져 있습니다. 표에서 1로 이루어진 가장 큰 정사각형을 찾아 넓이를 return 하는 solution 함수를 완성해 주세요. (단, 정사각형이란 축에 평행한 정사각형을 말합니다.)
현재 도전중인 문제..
너무 많은 경우의 수가 있어서 쉽게 접근을 못하는중..
자괴감 느낀다..
# 너무 뻔하게 생각을 해서 그런가 안 풀린다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*array의 각 element 중 divisor로 나누어 떨어지는 값을 오름차순으로 정렬한 배열을 반환하는 함수, solution을 작성해주세요.
divisor로 나누어 떨어지는 element가 하나도 없다면 배열에 -1을 담아 반환하세요.
제한사항
arr은 자연수를 담은 배열입니다.
정수 i, j에 대해 i ≠ j 이면 arr[i] ≠ arr[j] 입니다.
divisor는 자연수입니다.
array는 길이 1 이상인 배열입니다.
*/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
레벨 1 중에서 다음 레벨 문지기가 아닌가 싶을정도로 까다롭다.
실제로 700명밖에 못맞춤.. 나는 그 700명에 아직 포함이 안됨... 흑
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
위에 처럼 코드를 짯다.
물론 다른 블로그를 참고했다.
도저히 안떠올라서... 한시간 이상 못 풀면 못푼다고 하니까 ^^;;
최초에 고민했던 부분은 어느 시점을 trigger로 삼느냐였다.
어떤 조건으로부터 시작 하느냐에 대한 고민이었는데
최고의 방법은 역시 모두 다 하는 것이다.
모든 경우를 다 찾는 것, 그리고 그 걸 거꾸로 햇을때 같은것을 찾는것.
회문 문제이기에 stack을 사용하려 했으나
이 문제는 스택 여부가 아닌 회문 길이를 구하는 문제이므로 pass
비교의 경우 equals, == 이 있는데
==는 주소값을 비교하므로 문자열을 비교할때는 equals를 쓰는것이 맞다.
다만 위 방법은 효율성 점수가 0이라 수정을 해야한다.
O(N^2)이라 그런듯..
/* 배열 arr가 주어집니다. 배열 arr의 각 원소는 숫자 0부터 9까지로 이루어져 있습니다.
* 이때, 배열 arr에서 연속적으로 나타나는 숫자는 하나만 남기고 전부 제거하려고 합니다.
* 배열 arr에서 제거 되고 남은 수들을 return 하는 solution 함수를 완성해 주세요.
* 단, 제거된 후 남은 수들을 반환할 때는 배열 arr의 원소들의 순서를 유지해야 합니다.
예를들면
arr = [1, 1, 3, 3, 0, 1, 1] 이면 [1, 3, 0, 1] 을 return 합니다.
arr = [4, 4, 4, 3, 3] 이면 [4, 3] 을 return 합니다.
배열 arr에서 연속적으로 나타나는 숫자는 제거하고 남은 수들을 return 하는 solution 함수를 완성해 주세요.
제한사항
배열 arr의 크기 : 1,000,000 이하의 자연수
배열 arr의 원소의 크기 : 0보다 크거나 같고 9보다 작거나 같은 정수*/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getMiddle메소드는 하나의 단어를 입력 받습니다. 단어를 입력 받아서 가운데 글자를 반환하도록 getMiddle메소드를 만들어 보세요.
단어의 길이가 짝수일경우 가운데 두글자를 반환하면 됩니다.
예를들어 입력받은 단어가 power이라면 w를 반환하면 되고, 입력받은 단어가 test라면 es를 반환하면 됩니다.
기본적인 문제, 길이를 읽고, 짝수 홀수를 확인하고, 인덱스로 자른다.
파이썬과 다른게 있다면 파이썬은 문자->리스트-> 슬라이싱 이렇게 하면 되지만
자바의 경우에는 substring메서드를 이용하면 된다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters