[프로그래머스] 섬 연결하기 level-3 [JAVA]
출처 : programmers.co.kr/learn/courses/30/lessons/42861 코딩테스트 연습 - 섬 연결하기 4 [[0,1,1],[0,2,2],[1,2,5],[1,3,1],[2,3,8]] 4 programmers.co.kr 풀이 1. 크루스칼 알고리즘 2. 우선순위 큐 사용 코드 import java.util.*; class Solution { public static class Island implements Comparable{ int from ; int to; int weight; public Island(int from, int to, int weight){ this.from = from; this.to = to; this.weight = weight; } public int ..
[프로그래머스] 가장 큰 수 [JAVA]
출처 : programmers.co.kr/learn/courses/30/lessons/42746 코딩테스트 연습 - 가장 큰 수 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 programmers.co.kr 알게된 점 1. 정수형 -> 문자열로 바꾸는 법 1-1) String.valueOf( 정수 ) 1-2) Integer.toString( 정수 ) 2. 문자열 크기 비교하기 1-1) "3".compareTo("30") - 사전 순으로 작으면 -1 , 같으면 0 , 크면 1 return; - 3 < 30 으..