Skip to content

Commit

Permalink
solve : 11478 서로 다른 부분 문자열의 개수
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed Dec 20, 2024
1 parent d1a8b19 commit 071ebe9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions java/src/boj11478/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package boj11478;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

public static void main(String[] args) {
String input = readLine();
Set<String> set = new HashSet<>();

for (int i = 0; i < input.length(); i++) {
for (int j = i + 1; j <= input.length(); j++) {
set.add(input.substring(i, j));
}
}

System.out.println(set.size());
}

private static String readLine() {
try {
return reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit 071ebe9

Please sign in to comment.