{"id":339,"date":"2020-06-20T22:34:38","date_gmt":"2020-06-20T22:34:38","guid":{"rendered":"http:\/\/feellikelearning.com\/?p=339"},"modified":"2020-06-20T22:37:15","modified_gmt":"2020-06-20T22:37:15","slug":"leetcode-210-course-schedule-ii","status":"publish","type":"post","link":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/","title":{"rendered":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5"},"content":{"rendered":"\n<p>\u8fd9\u9898\u57fa\u672c\u548c<a href=\"http:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-269-alien-dictionary-solution\/\">269 alien dictionary<\/a>\u4e00\u6837\uff0c\u96be\u5ea6\u4e3amedium\u3002\u5176\u5b9e<a href=\"http:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-269-alien-dictionary-solution\/\">269 alien dictionary<\/a>\u6bd4\u8fd9\u9898\u591a\u4e86\u5c31\u662f\u5efagraph\u7684\u8fc7\u7a0b\u800c\u8fd9\u9898\u7684graph\u57fa\u672c\u662f\u5df2\u7ecf\u7ed9\u5b9a\u7684\u3002\u91cd\u70b9\u8fd8\u662ftopological sort\u90e8\u5206\u3002\u6bd4<a href=\"http:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-207-course-schedule-solution\/?preview_id=334&amp;preview_nonce=af1424952c&amp;preview=true\">207. Course Schedule<\/a>\u591a\u4e86\u4e24\u884chandle sort\u90e8\u5206\u3002\u4ee5\u4e0b\u4e3a\u540c\u6837\u601d\u8def\u7684python\u89e3\u6cd5\uff0c\u6bd4\u8f83\u7b80\u77ed\uff0c\u5bb9\u6613\u5199\u5bf9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution:\n    def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:\n        edges = {c: set() for c in range(numCourses)}\n        for pr in prerequisites:\n            edges[pr[1]].add(pr[0])\n            \n        order = []\n        seen = {}\n        \n        def dfs(start):\n            if start in seen:\n                return seen[start]\n            seen[start] = False\n            for nxt in edges[start]:\n                if not dfs(nxt):\n                    return False\n            seen[start] = True\n            order.insert(0, start)\n            return True\n            \n        if not all(dfs(start) for start in range(numCourses)):\n            return []\n        return order<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u9898\u57fa\u672c\u548c269 alien dictionary\u4e00\u6837\uff0c\u96be\u5ea6\u4e3amedium\u3002\u5176\u5b9e269 alien dictionary\u6bd4\u8fd9\u9898\u591a\u4e86\u5c31\u662f\u5efagraph\u7684\u8fc7\u7a0b\u800c\u8fd9\u9898\u7684graph\u57fa\u672c\u662f\u5df2\u7ecf\u7ed9\u5b9a\u7684\u3002\u91cd\u70b9\u8fd8\u662ftopological sort\u90e8\u5206\u3002\u6bd4207. Course Schedule\u591a\u4e86\u4e24\u884chandle sort\u90e8\u5206\u3002\u4ee5\u4e0b\u4e3a\u540c\u6837\u601d\u8def\u7684python\u89e3\u6cd5\uff0c\u6bd4\u8f83\u7b80\u77ed\uff0c\u5bb9\u6613\u5199\u5bf9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u9898\u57fa\u672c\u548c269 alien dictionary\u4e00\u6837\uff0c\u96be\u5ea6\u4e3amedium\u3002\u5176\u5b9e269 alien dictionary\u6bd4\u8fd9\u9898\u591a\u4e86\u5c31\u662f\u5efagraph\u7684\u8fc7\u7a0b\u800c\u8fd9\u9898\u7684graph\u57fa\u672c\u662f\u5df2\u7ecf\u7ed9\u5b9a\u7684\u3002\u91cd\u70b9\u8fd8\u662ftopological sort\u90e8\u5206\u3002\u6bd4207. Course Schedule\u591a\u4e86\u4e24\u884chandle sort\u90e8\u5206\u3002\u4ee5\u4e0b\u4e3a\u540c\u6837\u601d\u8def\u7684python\u89e3\u6cd5\uff0c\u6bd4\u8f83\u7b80\u77ed\uff0c\u5bb9\u6613\u5199\u5bf9\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\" \/>\n<meta property=\"og:site_name\" content=\"Feel Like Learning\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-20T22:34:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-20T22:37:15+00:00\" \/>\n<meta name=\"author\" content=\"feellikelearning\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"feellikelearning\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#article\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\"},\"author\":{\"name\":\"feellikelearning\",\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"headline\":\"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5\",\"datePublished\":\"2020-06-20T22:34:38+00:00\",\"dateModified\":\"2020-06-20T22:37:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\"},\"wordCount\":18,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\",\"url\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\",\"name\":\"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/#website\"},\"datePublished\":\"2020-06-20T22:34:38+00:00\",\"dateModified\":\"2020-06-20T22:37:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/feellikelearning.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/feellikelearning.com\/#website\",\"url\":\"https:\/\/feellikelearning.com\/\",\"name\":\"Feel Like Learning\",\"description\":\"\u7a0b\u5e8f\uff5c\u751f\u6d3b\uff5c\u5b66\u5230\u5c31\u662f\u8d5a\u5230\",\"publisher\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/feellikelearning.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\",\"name\":\"feellikelearning\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g\",\"caption\":\"feellikelearning\"},\"logo\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/feellikelearning.com\/index.php\/author\/feellikelearning\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant","og_locale":"en_US","og_type":"article","og_title":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning","og_description":"\u8fd9\u9898\u57fa\u672c\u548c269 alien dictionary\u4e00\u6837\uff0c\u96be\u5ea6\u4e3amedium\u3002\u5176\u5b9e269 alien dictionary\u6bd4\u8fd9\u9898\u591a\u4e86\u5c31\u662f\u5efagraph\u7684\u8fc7\u7a0b\u800c\u8fd9\u9898\u7684graph\u57fa\u672c\u662f\u5df2\u7ecf\u7ed9\u5b9a\u7684\u3002\u91cd\u70b9\u8fd8\u662ftopological sort\u90e8\u5206\u3002\u6bd4207. Course Schedule\u591a\u4e86\u4e24\u884chandle sort\u90e8\u5206\u3002\u4ee5\u4e0b\u4e3a\u540c\u6837\u601d\u8def\u7684python\u89e3\u6cd5\uff0c\u6bd4\u8f83\u7b80\u77ed\uff0c\u5bb9\u6613\u5199\u5bf9\u3002","og_url":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant","og_site_name":"Feel Like Learning","article_published_time":"2020-06-20T22:34:38+00:00","article_modified_time":"2020-06-20T22:37:15+00:00","author":"feellikelearning","twitter_card":"summary_large_image","twitter_misc":{"Written by":"feellikelearning"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#article","isPartOf":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant"},"author":{"name":"feellikelearning","@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"headline":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5","datePublished":"2020-06-20T22:34:38+00:00","dateModified":"2020-06-20T22:37:15+00:00","mainEntityOfPage":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant"},"wordCount":18,"commentCount":0,"publisher":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#respond"]}]},{"@type":"WebPage","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant","url":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant","name":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5 | Feel Like Learning","isPartOf":{"@id":"https:\/\/feellikelearning.com\/#website"},"datePublished":"2020-06-20T22:34:38+00:00","dateModified":"2020-06-20T22:37:15+00:00","breadcrumb":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/06\/20\/leetcode-210-course-schedule-ii\/?variant=zh-hant#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/feellikelearning.com\/"},{"@type":"ListItem","position":2,"name":"\u7b97\u6cd5\u7ec3\u4e60 Leetcode \u529b\u6263 210. Course Schedule II \u89e3\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/feellikelearning.com\/#website","url":"https:\/\/feellikelearning.com\/","name":"Feel Like Learning","description":"\u7a0b\u5e8f\uff5c\u751f\u6d3b\uff5c\u5b66\u5230\u5c31\u662f\u8d5a\u5230","publisher":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/feellikelearning.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a","name":"feellikelearning","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/72a1e86e9dcb0332e88bd7d54fd36c28?s=96&d=mm&r=g","caption":"feellikelearning"},"logo":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/image\/"},"url":"https:\/\/feellikelearning.com\/index.php\/author\/feellikelearning\/"}]}},"_links":{"self":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/339"}],"collection":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":3,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/339\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}