Skip to content

Commit 98f101e

Browse files
committed
124차 1번 문제풀이
1 parent 3b1331c commit 98f101e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n');
6+
7+
const S = input[0];
8+
const P = input[1];
9+
10+
let index = 0;
11+
let count = 0;
12+
13+
while (index < P.length) {
14+
let maxLen = 0;
15+
16+
for (let j = 0; j < S.length; j++) {
17+
let temp = 0;
18+
while (
19+
index + temp < P.length &&
20+
j + temp < S.length &&
21+
P[index + temp] === S[j + temp]
22+
) {
23+
temp++;
24+
}
25+
if (temp > maxLen) {
26+
maxLen = temp;
27+
}
28+
}
29+
30+
index += maxLen;
31+
count++;
32+
}
33+
34+
console.log(count);

0 commit comments

Comments
 (0)