BackJoon Algorithm 11656 접미사 배열 (Java)

업데이트:
최대 1 분 소요

BackJoon Algorithm - Java

alt

문제

alt

풀이

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Back_11656 {
    public static void main(String[] args) throws IOException {

        // given
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String[] str = new String[S.length()];
        // when
        for(int i=0;i<S.length();i++){
            String S_charAt="";
            for(int j=i;j<S.length();j++){
                S_charAt+=S.charAt(j);
            }
            str[i]=S_charAt;
        }
        Arrays.sort(str);
        // then
        br.close();
        for (String s : str) {
            System.out.println(s);
        }
    }
}

댓글남기기