-
Notifications
You must be signed in to change notification settings - Fork 0
/
줄 세우기(백준).js
56 lines (49 loc) · 1.08 KB
/
줄 세우기(백준).js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// acmicpc.net/problem/11536
// const target = ['HOPE',
// 'ALI',
// 'BECKY',
// 'JULIE',
// 'MEGHAN',
// 'LAUREN',
// 'MORGAN',
// 'CARLI',
// 'MEGAN',
// 'ALEX',
// 'TOBIN'];
const target = ['JOE',
'BOB',
'ANDY',
'AL',
'ADAM']
// const target = ['GEORGE',
// 'JOHN',
// 'PAUL',
// 'RINGO']
let result = '';
const store = [];
const isNeitherCheck = (num) => {
let isNeither = false;
store.push(num);
if(store.length > 1){
for(let i = 0 ; i < store.length ; i++){
if(store[i+1] !== undefined && store[i] !== store[i+1]){
isNeither = true;
}
}
}
return isNeither;
}
for(let i = 0 ; i < target.length ; i++){
if(target[i+1] !== undefined){
if(isNeitherCheck(target[i].localeCompare(target[i+1]))){
result = 'neither';
};
if(!isNeitherCheck(target[i].localeCompare(target[i+1])) && target[i].localeCompare(target[i+1]) < 0){
result = 'INCREASING';
}
else if(!isNeitherCheck(target[i].localeCompare(target[i+1])) && target[i].localeCompare(target[i+1]) === 1){
result = 'DECREASING';
}
}
}
console.log(result);