-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q11656.java
30 lines (27 loc) · 1.13 KB
/
Q11656.java
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
/**
* Date: 2018. 07. 30.
* Author: inhyuck | https://github.com/inhyuck
* Solution URL: https://github.com/skhucode/skhucode-inhyuck
* Title: 접미사 배열
* Problem: 접미사 배열은 문자열 S의 모든 접미사를 사전순으로 정렬해 놓은 배열이다.
* baekjoon의 접미사는 baekjoon, aekjoon, ekjoon, kjoon, joon, oon, on, n 으로 총 8가지가 있고,
* 이를 사전순으로 정렬하면, aekjoon, baekjoon, ekjoon, joon, kjoon, n, on, oon이 된다.
* 문자열 S가 주어졌을 때, 모든 접미사를 사전순으로 정렬한 다음 출력하는 프로그램을 작성하시오.
* URL: https://www.acmicpc.net/problem/11656
*/
package io.inhyuck.collections;
import java.util.*;
public class Q11656 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < line.length(); i++) {
list.add(line.substring(i));
}
Collections.sort(list);
for (String str : list) {
System.out.println(str);
}
}
}