Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- 투포인터
- 건강
- COS PRO
- 문제풀이
- 문제해결
- SQL
- greedy
- SWEA
- 백준
- 이분탐색
- 코테
- math
- BOJ
- 자바
- 문자열
- 시뮬레이션
- dfs
- 코딩테스트
- oracle
- BFS
- 알고리즘
- DP
- 프로그래머스
- db
- priorityqueue
- 러닝일지
- MySQL
- binary search
- Java
- 운동기록
Archives
- Today
- Total
슈콩
COS PRO 1급 규칙에 맞는 배열 구하기 본문



[소스 코드]
import java.util.*;
class Main {
public int[] solution(int[] arr) {
[[(guide-anchor):(한줄을 수정하시오)]]
int left = 0, right = arr.length - 1;
int idx = 0;
int[] answer = new int[arr.length];
while(left <= right){
if(idx % 2 == 0){
answer[idx] = arr[left];
left += 1;
}
else{
answer[idx] = arr[right];
right -= 1;
}
idx += 1;
}
return answer;
}
}