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
- 건강
- 이분탐색
- DP
- 문자열
- BOJ
- BFS
- 코테
- 알고리즘
- 코딩테스트
- oracle
- 운동기록
- 프로그래머스
- binary search
- SWEA
- SQL
- 러닝일지
- greedy
- math
- 시뮬레이션
- 문제해결
- 투포인터
- Java
- MySQL
- 자바
- db
- dfs
- 백준
- 문제풀이
- priorityqueue
- COS PRO
Archives
- Today
- Total
슈콩
COS PRO 1급 JAVA 배열을 회전시켜보세요 본문
[문제]



[소스 코드]
class Main {
int[] func_a(int[] arr) {
int length = arr.length;
int[] ret = new int[length*2];
for(int i = 0; i < length; i++)
ret[i + length] = ret[i] = arr[i];
return ret;
}
boolean func_b(int[] first, int[] second){
int[] counter = new int[1001];
for(int i = 0; i < first.length; i++){
counter[first[i]]++;
counter[second[i]]--;
}
for(int i = 0; i < 1001; i++)
if(counter[i] != 0)
return false;
return true;
}
boolean func_c(int[] first, int[] second){
int length = second.length;
for(int i = 0; i < length; i++){
int j;
for(j = 0; j < length; j++)
if(first[i + j] != second[j])
break;
if(j == length)
return true;
}
return false;
}
public boolean solution(int[] arrA, int[] arrB) {
if(arrA.length != arrB.length)
return false;
if(func_b(arrA,arrB)) {
int[] arrAtemp = func_a(arrA);
if(func_c(arrAtemp,arrB))
return true;
}
return false;
}
}