강의로 돌아가기

### 테스트케이스 1번만 실패해요

힌트좀 부탁드립니다.
(혹시 아시면 테스트케이스 1번이 무엇인지 좀 부탁드려요)
참고로 재귀로 풀었습니다..

###### 작성중인 코드―Solution.java
``````1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Solution {
public String[] solution(String[][] tickets) {
String[] answer = new String[tickets.length + 1];
Set<Ticket> ticketSet = new TreeSet<>();

for (String[] ticketStr : tickets) {
Ticket ticket = new Ticket();

ticket.start = ticketStr[0];
ticket.end = ticketStr[1];

}

List<String> reversedPath = getReversedPath("ICN", ticketSet);

for (int i = 0; i < reversedPath.size(); i++) {
}

}

private List<String> getReversedPath(String start, Set<Ticket> tickets) {
List<String> reversedPath = null;

if (tickets.isEmpty()) {
reversedPath = new ArrayList<>();
return reversedPath;
}

Set<Ticket> tmpTickets = new TreeSet<>();

for (Ticket ticket : tickets) {
if (!ticket.start.equals(start)) {
continue;
}

tmpTickets.remove(ticket);
reversedPath = getReversedPath(ticket.end, tmpTickets);

if (reversedPath != null) {
break;
}
}

return reversedPath;
}

private class Ticket implements Comparable<Ticket> {
String start;
String end;

@Override
public int compareTo(Ticket that) {
int startComp = this.start.compareTo(that.start);

if (startComp != 0) {
return startComp;
}

return this.end.compareTo(that.end);
}

@Override
public int hashCode() {
return (start + "," + end).hashCode();
}
}
}
``````