Skip to content

Commit 1676f46

Browse files
committed
알고리즘 풀이 업데이트
1 parent 7f2c059 commit 1676f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1200
-56
lines changed

.DS_Store

0 Bytes
Binary file not shown.

섹션1/10.문자찾기.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s, t) {
9+
let answer = 0;
10+
for (let x of s) {
11+
if (x === t) answer++;
12+
}
13+
return answer;
14+
}
15+
16+
let str = 'COMPUTERPROGRAMMING';
17+
console.log(solution(str, 'R'));
18+
</script>
19+
</body>
20+
</html>

섹션1/11.대문자찾기.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = 0;
10+
for (let x of s) {
11+
if (x === x.toUpperCase()) {
12+
answer++;
13+
}
14+
}
15+
16+
return answer;
17+
}
18+
19+
let str = 'KoreaTimeGood';
20+
console.log(solution(str));
21+
</script>
22+
</body>
23+
</html>

섹션1/12.대문자통일.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
answer = str.toUpperCase();
12+
13+
return answer;
14+
}
15+
16+
let str = 'ItisTimeToStudy';
17+
console.log(solution(str));
18+
</script>
19+
</body>
20+
</html>

섹션1/13.대소문자변환.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
for (let x of s) {
12+
//대문자라면
13+
if (x === x.toUpperCase()) answer += x.toLowerCase();
14+
//소문자라면
15+
else answer += x.toUpperCase();
16+
}
17+
18+
return answer;
19+
}
20+
21+
console.log(solution('StuDY'));
22+
</script>
23+
</body>
24+
</html>

섹션1/14.가장긴문자열.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
let max = Number.MIN_SAFE_INTEGER;
12+
13+
for (let x of s) {
14+
if (max < x.length) {
15+
max = x.length;
16+
answer = x;
17+
}
18+
}
19+
20+
return answer;
21+
}
22+
let str = ['teacher', 'time', 'student', 'beautiful', 'good'];
23+
console.log(solution(str));
24+
</script>
25+
</body>
26+
</html>

섹션1/15.가운데문자출력.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
let mid = Math.floor(s.length / 2);
12+
//홀수인경우
13+
if (s.length % 2 === 1) {
14+
answer = s.substring(mid, mid + 1);
15+
}
16+
//짝수인경우
17+
else {
18+
answer += s.substring(mid - 1, mid + 1);
19+
}
20+
21+
//홀수일경우
22+
23+
return answer;
24+
}
25+
console.log(solution('stdd'));
26+
</script>
27+
</body>
28+
</html>

섹션1/16.중복문자제거.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
// for (let x of s) {
12+
// if (!answer.includes(x)) answer = answer + x;
13+
// }
14+
15+
for (let i = 0; i < s.length; i++) {
16+
console.log(s.indexOf(s[i]));
17+
}
18+
19+
return answer;
20+
}
21+
console.log(solution('ksekkset'));
22+
</script>
23+
</body>
24+
</html>

섹션1/17.중복단어제거.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer;
10+
//console.log(s.indexOf("time"));
11+
answer = s.filter(function (v, i) {
12+
return s.indexOf(v) === i;
13+
});
14+
return answer;
15+
}
16+
let str = ['good', 'time', 'good', 'time', 'student'];
17+
console.log(solution(str));
18+
</script>
19+
</body>
20+
</html>

섹션1/3.연필개수.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(n) {
9+
let answer;
10+
answer = Math.ceil(n / 12);
11+
return answer;
12+
}
13+
14+
console.log(solution(178));
15+
</script>
16+
</body>
17+
</html>

섹션1/4.1부터N까지의합.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(n) {
9+
let answer = 0;
10+
for (let i = 1; i <= n; i++) {
11+
answer = answer + i;
12+
}
13+
return answer;
14+
}
15+
16+
console.log(solution(10));
17+
</script>
18+
</body>
19+
</html>
20+
s

섹션1/5.최솟값.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(arr) {
9+
let answer = Number.MAX_SAFE_INTEGER;
10+
11+
answer = Math.min(...arr);
12+
return answer;
13+
}
14+
15+
let arr = [5, 7, 1, 3, 2, 9, 11];
16+
console.log(solution(arr));
17+
</script>
18+
</body>
19+
</html>

섹션1/6.홀수.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(arr) {
9+
let answer = [];
10+
11+
let sum = 0;
12+
let min = Number.MAX_SAFE_INTEGER;
13+
14+
for (let i = 0; i < arr.length; i++) {
15+
if (arr[i] % 2 === 1) {
16+
sum = sum + arr[i];
17+
if (min > arr[i]) {
18+
min = arr[i];
19+
}
20+
}
21+
}
22+
23+
answer.push(sum);
24+
answer.push(min);
25+
26+
return answer;
27+
}
28+
29+
arr = [12, 77, 38, 41, 53, 92, 85];
30+
console.log(solution(arr));
31+
</script>
32+
</body>
33+
</html>

섹션1/7.10부제.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(day, arr) {
9+
let answer = 0;
10+
for (let i = 0; i < arr.length; i++) {
11+
if (arr[i] % 10 === day) {
12+
answer++;
13+
}
14+
}
15+
return answer;
16+
}
17+
18+
arr = [25, 23, 11, 47, 53, 17, 33];
19+
console.log(solution(3, arr));
20+
</script>
21+
</body>
22+
</html>

섹션1/8.일곱난쟁이.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(arr) {
9+
let answer = arr;
10+
let sum = arr.reduce((a, b) => a + b, 0);
11+
for (let i = 0; i < 8; i++) {
12+
for (let j = 1; j < 9; j++) {
13+
if (sum - (arr[i] + arr[j]) === 100) {
14+
answer.splice(i, 1);
15+
answer.splice(j, 1);
16+
}
17+
}
18+
}
19+
return answer;
20+
}
21+
22+
let arr = [20, 7, 23, 19, 10, 15, 25, 8, 13];
23+
console.log(solution(arr));
24+
</script>
25+
</body>
26+
</html>

섹션1/9.A를#으로.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(s) {
9+
let answer = '';
10+
11+
for (let x of s) {
12+
if (x === 'A') answer += '#';
13+
else answer += x;
14+
}
15+
return answer;
16+
}
17+
18+
let str = 'BANANA';
19+
console.log(solution(str));
20+
</script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)