摘要:
https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges ti 阅读全文
摘要:
单源最短路径 给定一个图,和一个源顶点src,找到从src到其它所有所有顶点的最短路径,图中可能含有负权值的边。 Dijksra的算法是一个贪婪算法,时间复杂度是O(VLogV)(使用最小堆)。但是迪杰斯特拉算法在有负权值边的图中不适用,Bellman-Ford适合这样的图。在网络路由中,该算法会被 阅读全文
摘要:
Python内置的heapq模块 Python3.4版本中heapq包含了几个有用的方法:heapq.heappush(heap,item):将item,推入heap >>> items = [1,2,9,7,3] >>> heapq.heappush(items,10) >>> items [1, 阅读全文
摘要:
819. Most Common Word Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guara 阅读全文
摘要:
703. Kth Largest Element in a Stream Easy Easy Design a class to find the kth largest element in a stream. Note that it is the kth largest element in 阅读全文