Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6ae73f7

Browse files
committed
이예진: [PG] 118669 등산코스 정하기_241213 주석수정
1 parent fd24568 commit 6ae73f7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

‎Programmers/Level3/YJ_118669.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public int compareTo(Node o) {
1818

1919
List<ArrayList<Node>> graph = new ArrayList<>();
2020
int[] table;
21-
Set<Integer> summitSet = new HashSet<>();
21+
List<Integer> summitSet = new ArrayList<>();
2222
public int[] solution(int n, int[][] paths, int[] gates, int[] summits) {
23-
//산봉우리 중복제거
23+
//산봉우리 확인용
2424
for(int mountain : summits){
2525
summitSet.add(mountain);
2626
}
27-
//최소 가중치 테이블 초기화
27+
//최소 intensity 테이블 초기화
2828
table = new int[n+1];
2929
Arrays.fill(table, Integer.MAX_VALUE);
3030
//그래프 모델링
@@ -44,7 +44,7 @@ public int[] solution(int n, int[][] paths, int[] gates, int[] summits) {
4444
int[] answer = {0,Integer.MAX_VALUE};
4545
for (int mountain : summits) {
4646
int intensity = answer[1];
47-
if (table[mountain] < intensity) { //intensity의 최솟값
47+
if (table[mountain] < intensity) { //최소 intensity 구하기
4848
answer[0] = mountain;
4949
answer[1] = table[mountain];
5050
} else if (table[mountain] == intensity && mountain < answer[0]) {
@@ -54,8 +54,7 @@ public int[] solution(int n, int[][] paths, int[] gates, int[] summits) {
5454
return answer;
5555
}
5656

57-
// 휴식 없이 이동해야 하는 시간 중 가장 긴 시간을 해당 등산코스의 intensity (가중치)
58-
// 출입구는 처음과 끝에 한 번씩, 산봉우리는 한 번만 포함 -> 출발 > 산봉우리 까지의 거리
57+
// 출입구는 처음과 끝에 한 번씩, 산봉우리는 한 번만 포함 -> 출발 > 산봉우리 까지의 단방향 거리만 구하면됨
5958
void dijkstra(int[] gates){
6059
PriorityQueue<Node> pq = new PriorityQueue<>();
6160
//출발지점으로 초기화
@@ -78,8 +77,8 @@ void dijkstra(int[] gates){
7877

7978
for(Node next : graph.get(index)){
8079
int nextIndex = next.index;
81-
int cost = Math.max(table[index], next.distance);
82-
if(table[nextIndex] > cost){
80+
int cost = Math.max(table[index], next.distance);//현재 지점에서 다음 지점으로 갈 때 가장 긴 등산코스(intensity)를 찾기
81+
if(table[nextIndex] > cost){//그 중 최소 intensity 찾기
8382
table[nextIndex] = cost;
8483
pq.offer(new Node(nextIndex, cost));
8584
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /