Leetcode 332. Reconstruct Itinerary
来源:互联网 发布:金兰软件怎么样 编辑:程序博客网 时间:2024/05/22 07:42
public class Solution { Map<String, PriorityQueue<String>> flights; LinkedList<String> path; public List<String> findItinerary(String[][] tickets) { flights = new HashMap<>(); path = new LinkedList<>(); for (String[] ticket : tickets) { flights.putIfAbsent(ticket[0], new PriorityQueue<>()); flights.get(ticket[0]).add(ticket[1]); } dfs("JFK"); return path; } public void dfs(String departure) { PriorityQueue<String> arrivals = flights.get(departure); while (arrivals != null && !arrivals.isEmpty()) dfs(arrivals.poll()); path.addFirst(departure); }}
0 0
- *[LeetCode]332. Reconstruct Itinerary
- leetcode 332. Reconstruct Itinerary
- LeetCode *** 332. Reconstruct Itinerary
- LeetCode 332. Reconstruct Itinerary
- leetcode 332. Reconstruct Itinerary
- [leetcode] 332. Reconstruct Itinerary
- Leetcode 332. Reconstruct Itinerary
- Leetcode 332. Reconstruct Itinerary
- Leetcode 332. Reconstruct Itinerary
- [LeetCode]332. Reconstruct Itinerary
- Leetcode: 332.Reconstruct Itinerary
- leetcode:332. Reconstruct Itinerary
- LeetCode 332. Reconstruct Itinerary
- [leetcode]332. Reconstruct Itinerary
- [LeetCode] 332. Reconstruct Itinerary
- leetcode 332. Reconstruct Itinerary
- [LeetCode]332. Reconstruct Itinerary
- LeetCode 332. Reconstruct Itinerary【medium】
- 这才是2017年规划---贫穷来自于懒惰
- 153. Find Minimum in Rotated Sorted Array
- 总结一下学习vb串口通信的初期果实
- 扩展LDBSCAN 算法在图上的应用
- wamp+win10: php连接Mysql, delete update insert 详细操作步骤
- Leetcode 332. Reconstruct Itinerary
- Eularian Path
- 火星人的真实故事,读后感言
- 计算机图形学-初入门(小作品)
- 【LeetCode】 075. Sort Colors
- 还要和师兄混
- mmw mimo系统预编码
- 7107小时时,加入创业公司(没有股份,当作经验吧)
- [Leetcode] 63. Unique Paths II 解题报告