Skip to content

Commit c45bd34

Browse files
committed
Distinct substrings / 중급
1 parent fb0ec7a commit c45bd34

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// https://www.acmicpc.net/problem/11478
2+
3+
const filePath =
4+
process.platform === "linux"
5+
? "/dev/stdin"
6+
: require("path").join(__dirname, "input.txt")
7+
const input = require("fs").readFileSync(filePath).toString().trim()
8+
const log = console.log
9+
10+
// 서로 다른 부분 문자열의 개수 출력하기
11+
// 길이는 1,000 이하.
12+
const set = new Set()
13+
for (let i = 0; i < input.length; i++) {
14+
for (let j = i; j < input.length; j++) {
15+
const sliced = input.slice(i, j + 1)
16+
set.add(sliced)
17+
}
18+
}
19+
log(set.size)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ababc

0 commit comments

Comments
 (0)