[백준] P1181

동민·2021년 3월 11일
0
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class P1181 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		List<String> list = new ArrayList<String>();

		for (int i = 0; i < n; i++) {

			String str = sc.next();
			list.add(str);
		}

		Collections.sort(list);

		Collections.sort(list, (s1, s2) -> {

			if (s1.length() > s2.length()) {
				return 1;
			} else if (s1.length() < s2.length()) {
				return -1;
			}
			return 0;

		});

		String temp = " ", str;
		for (int i = 0; i < n; i++) {

			str = list.get(i);

			if (!temp.equals(str)) {
				System.out.println(str);
			}
			temp = str;
		}

		sc.close();

	}

}
profile
BE Developer

0개의 댓글