본문 바로가기
Algorithm/BaekJoon[Java]

백준 11656

by 씨니 2022. 3. 25.
728x90

▶ 백준 11656 문제 - 접미사 배열

 

▶ 풀이방법

import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		String str = br.readLine();
		ArrayList<String> list = new ArrayList<>();
		
		for(int i = 0; i < str.length(); i++) {
			list.add(str.substring(i));
		}
		
		Collections.sort(list);
		
		for(int i = 0; i < list.size(); i++) {
			bw.write(list.get(i) + "\n");
		}
		bw.flush();
		bw.close();
		br.close();
	}
}
728x90

'Algorithm > BaekJoon[Java]' 카테고리의 다른 글

백준 10808  (0) 2022.03.25
백준 10824  (0) 2022.03.25
백준 10866 (Deque)  (0) 2022.03.24
백준 10845 (Queue)  (0) 2022.03.24
백준 10799  (0) 2022.03.24