


When someone told me to use Floyd Warshall Algorithm, I immediately knew what to do. But I still don’t get the intuit when to use it.
When someone told me to use Floyd Warshall Algorithm, I immediately knew what to do. But I still don’t get the intuit when to use it.
我一开始用的tree traversal, 但很蠢地把所有课的所有prerequisite都存下来。实际只需要对queries进行遍历,所以每次建立visited再遍历就行。它甚至不需要把曾经遍历过的节点存下来。
bfs也很直观,首先找出没有前置课的节点入queue,然后逐渐扩散保存就行,这个方法就可以全存下来。我明明都会,为啥没做出来???