-
Notifications
You must be signed in to change notification settings - Fork 4
/
배열회전.cpp
31 lines (30 loc) · 693 Bytes
/
배열회전.cpp
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
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool solution(vector<int> arrA, vector<int> arrB) {
if (arrA.size() != arrB.size())
return false;
else {
for (int i = 0; i < arrA.size(); i++) { // A 시작 위치
for (int j = 0; j < arrA.size(); j++) { // B 시작 위치
int count = 0;
for (int k = 0; k < arrA.size(); k++) { // 검사시작
int a = i + k;
int b = j + k;
if (a >= arrA.size())
a -= arrA.size();
if (b >= arrB.size())
b -= arrB.size();
if (arrA[a] != arrB[b])
break;
else
count++;
}
if (count == arrA.size())
return true;
}
}
}
return false;
}