{"id":962,"date":"2020-12-12T05:40:55","date_gmt":"2020-12-12T05:40:55","guid":{"rendered":"http:\/\/feellikelearning.com\/?p=962"},"modified":"2020-12-17T01:35:50","modified_gmt":"2020-12-17T01:35:50","slug":"cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python","status":"publish","type":"post","link":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/","title":{"rendered":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 &#8211; 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm &#8211; 0-1 knapsack problem explained in Python"},"content":{"rendered":"\n<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n\n\n\n<p>\u6709N\u4e2a\u7269\u54c1, \u6bcf\u4e2a\u7269\u54c1Cost\u4e3aC[i], Value\u4e3aW[i], \u5176\u4e2d i \u5c5e\u4e8e [0, &#8230;, N-1]<br>\u6709\u4e00\u4e2a\u4e66\u5305, \u5bb9\u91cf\u4e3aV<br>\u6c42\u4e66\u5305\u80fd\u88c5\u4e0b\u7684\u6700\u5927Value<\/p>\n\n\n\n<h3><strong>\u4e3a\u4ec0\u4e48\u53eb0-1\u80cc\u5305?<\/strong><\/h3>\n\n\n\n<!--more-->\n\n\n\n<p>\u56e0\u4e3a\u6bcf\u4e2a\u7269\u54c1\u53ea\u67092\u9009\u62e9: \u4e0d\u7528(0)\u6216\u8005\u7528(1). \u7269\u54c1\u4e0d\u80fd\u91cd\u590d\u4f7f\u7528. <\/p>\n\n\n\n<h2>\u66b4\u529b\u89e3\u6cd5<\/h2>\n\n\n\n<p>\u66b4\u529b\u6c42\u89e3\u5c31\u662f\u628aN\u4e2a\u7269\u54c1\u7684\u6240\u6709\u5b50\u96c6(Power Set)\u6c42\u51fa\u6765, \u7136\u540e\u770b\u770b\u6240\u6709Cost\u52a0\u8d77\u6765\u662f\u4e0d\u662f &lt;= \u80cc\u5305\u5bb9\u91cf V, \u5bf9\u6ee1\u8db3\u4ee5\u4e0a\u6761\u4ef6\u7684, \u9009\u51fa\u6700\u5927\u7684Value. <br>\u5b50\u96c6\u4e00\u5171\u67092^N\u4e2a, \u6240\u4ee5\u9700\u8981O(2^N)\u65f6\u95f4. <br>\u7528DFS(\u6df1\u5ea6\u4f18\u5148\u641c\u7d22)\u7684\u8bdd, \u9700\u8981O(N)\u7a7a\u95f4<\/p>\n\n\n\n<h2>2\u7ef4DP\u89e3\u6cd5<\/h2>\n\n\n\n<p>\u8fd9\u662f\u4e00\u79cd\u80cc\u5305\u56fa\u5b9a\u5957\u8def, \u9996\u5148\u521d\u59cb\u5316\u4e00\u4e2a2\u7ef4\u77e9\u9635dp, N+1\u884c, V+1\u5217. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"http:\/\/feellikelearning.com\/wp-content\/uploads\/2020\/12\/image-16.png\" alt=\"\" class=\"wp-image-963\" width=\"364\" height=\"228\"\/><\/figure>\n\n\n\n<p>\u7528 Python \u8868\u8fbe\u51fa\u6765\u5c31\u662f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>row = &#91;0] * (1 + V)\ndp = &#91;]\nfor i in range(N + 1):\n    dp.append(list(row))<\/code><\/pre>\n\n\n\n<p><code>dp[i][v] <\/code>\u4ee3\u8868\u7684\u610f\u4e49\u662f\u7b2c0\u5230\u7b2ci-1\u4e2a\u7269\u54c1 (\u524di\u4e2a\u7269\u54c1), \u5bb9\u91cf\u4e3av\u7684\u80cc\u5305, \u80fd\u653e\u7684\u6700\u5927\u4ef7\u503c<br>\u586b\u683c\u5b50\u7684\u65f6\u5019\u6211\u4eec\u4ece\u5de6\u5230\u53f3\u6309\u884c\u626b\u63cf, \u4e5f\u5c31\u662f\u5bf9\u4e00\u4e2a\u7279\u5b9a\u7269\u54c1, \u7b2ci-1\u4e2a, \u626b\u63cf\u6240\u6709\u53ef\u80fd\u7684\u5bb9\u91cf. \u5230\u7b2ci-1\u4e2a\u7269\u54c1\u7684\u65f6\u5019, \u5bb9\u91cf\u4e3av\u7684\u65f6\u5019, \u65e0\u975e\u4e24\u79cd\u9009\u62e9: <br>1. \u628a\u8fd9\u4e2a\u7269\u54c1\u653e\u8fdb\u53bb, \u90a3\u4e48v-C[i]\u9700\u8981\u5927\u4e8e\u6216\u7b49\u4e8e0, \u5426\u5219\u653e\u4e0d\u4e0b, \u65b0\u7684\u6700\u5927value\u4e3a <code>dp[i-1][v-C[i]] + W[i]<\/code><br>2. \u4e0d\u628a\u8fd9\u4e2a\u7269\u54c1\u653e\u8fdb\u53bb. \u4e3a\u4ec0\u4e48\u4e0d\u653e? \u56e0\u4e3a\u653e\u4e0d\u8fdb\u4e86\u554a. value\u4e3a <code>dp[i-1][v]<\/code><\/p>\n\n\n\n<p>dp[i][v]\u9700\u8981\u653e\u8fd9\u4e24\u79cd\u60c5\u51b5\u4e2dvalue\u5927\u7684\u90a3\u79cd. \u7528python\u8868\u8fbe\u5c31\u662f, \u5148\u628adp[i][v]\u8bbe\u6210\u4e0d\u653e\u7684\u60c5\u51b5, \u5982\u679c\u53ef\u4ee5\u653e\u7684\u8bdd(v-C[i] &gt;=  0), \u5e76\u4e14\u653e\u4e86Value\u589e\u52a0\u4e86, \u5c31\u6362\u6210\u653e\u7684\u60c5\u51b5. \u7528Python\u8868\u8fbe\u51fa\u6765\u5c31\u662f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for i in range(1, N + 1):\n    for v in range(1, V + 1):\n        dp&#91;i]&#91;v] = dp&#91;i - 1]&#91;v]\n        if v - C&#91;i] &gt;= 0:\n            dp&#91;i]&#91;v] = max(\n                dp&#91;i]&#91;v], \n                dp&#91;i - 1]&#91;v - C&#91;i - 1]] + W&#91;i - 1]\n            )<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u4e0b\u6807\u6709\u70b9tricky. <code>dp[i][v]<\/code>\u4ee3\u8868\u7684\u610f\u4e49\u662f\u524di\u4e2a\u7269\u54c1, \u6240\u4ee5\u6700\u540e\u4e00\u4e2a\u7269\u54c1\u7684index\u662f<code>i-1<\/code> (\u7269\u54c1\u4e0b\u6807\u4ece0\u5f00\u59cb). \u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u8981\u7528<code>C[i - 1]<\/code>, <code>W[i - 1]<\/code>. \u5f88\u591a\u7eaf\u7406\u8bba\u7b97\u6cd5\u7528\u7684\u662f1 base\u7684index, \u8f6c\u6362\u6210code\u7684\u65f6\u5019\u8fd8\u6709\u70b9\u9ebb\u70e6. \u6211\u8fd9\u91cc\u7528\u7684\u5c31\u76f4\u63a5\u662fPython\u6216\u5927\u90e8\u5206\u8bed\u8a00\u80fd\u8dd1\u7684\u771fcode. dp[i][j] \u8d4b\u503c\u90e8\u5206\u5c31\u662f\u6240\u8c13\u7684DP\u8f6c\u79fb\u65b9\u7a0b. <\/p>\n\n\n\n<p>\u6700\u540e\u628a\u521d\u59cb\u5316, \u5faa\u73af\u548c\u8f6c\u79fb\u65b9\u7a0b\u8fde\u5728\u4e00\u8d77, \u5c31\u53ef\u4ee5\u7528 Python \u5b8c\u6574\u7684\u8868\u8fbe\u51fa\u6765<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def maxKnapsackValue(N, C, W, V):\n    # init dp\n    row = &#91;0] * (1 + V)\n    dp = &#91;]\n    for i in range(N + 1):\n        dp.append(list(row))\n\n    for i in range(1, N + 1):\n        for v in range(1, V + 1):\n            dp&#91;i]&#91;v] = dp&#91;i - 1]&#91;v]\n            if v - C&#91;i - 1] &gt;= 0:\n                dp&#91;i]&#91;v] = max(\n                    dp&#91;i]&#91;v], \n                    dp&#91;i - 1]&#91;v - C&#91;i - 1]] + W&#91;i - 1]\n                )\n    return dp&#91;N]&#91;V]<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u5c31\u662f Python \u7248\u672c\u76840-1\u80cc\u5305\u95ee\u9898\u76842\u7ef4DP\u5957\u8def\u89e3\u6cd5<\/p>\n\n\n\n<h2>2\u7ef4DP\u89e3\u6cd5\u5e94\u7528<\/h2>\n\n\n\n<p>\u4ee5\u4e0a\u603b\u7ed3\u76842\u7ef4DP\u89e3\u6cd5\u7684\u6a21\u7248\u53ef\u4ee5\u76f4\u63a5\u5e94\u7528\u5728Leetcode 416\u4e0a, \u8be6\u7ec6\u8bf7\u770b<a href=\"http:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-leetcode-416-partition-equal-subset-sum-using-0-1-knapsack-2d-dp-template-python-solution\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a>. <\/p>\n\n\n\n<h2>\u53c2\u8003\u8d44\u6599<\/h2>\n\n\n\n<p><a href=\"https:\/\/raw.githubusercontent.com\/tianyicui\/pack\/master\/V2.pdf\">\u5d14\u6dfb\u7ffc \u80cc\u5305\u95ee\u9898\u4e5d\u8bb2 2.0<\/a> \u539f\u6587\u6709\u4e9b\u7ec6\u8282\u8bb2\u5f97\u4e0d\u6e05\u695a, \u800c\u4e14\u6709\u4e9b\u4f2a\u4ee3\u7801\u8f6c\u6362\u6210\u771f\u4ee3\u7801\u65f6\u5019\u6709\u4e9b\u95ee\u9898, \u672c\u6587\u7528\u80fdrun\u7684\u771f\u4ee3\u7801\u5e76\u8bd5\u56fe\u628a\u7ec6\u8282\u4ea4\u4ee3\u6e05\u695a. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0 \u6709N\u4e2a\u7269\u54c1, \u6bcf\u4e2a\u7269\u54c1Cost\u4e3aC[i], Value\u4e3aW[i], \u5176\u4e2d i \u5c5e\u4e8e [0, &#8230;, N-1]\u6709\u4e00\u4e2a\u4e66\u5305, \u5bb9\u91cf\u4e3aV\u6c42\u4e66\u5305\u80fd\u88c5\u4e0b\u7684\u6700\u5927Value \u4e3a\u4ec0\u4e48\u53eb0-1\u80cc\u5305?<\/p>\n","protected":false},"author":1,"featured_media":1027,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[18,10,16,15,3,17],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.10 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | 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\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | Feel Like Learning\" \/>\n<meta property=\"og:description\" content=\"\u95ee\u9898\u63cf\u8ff0 \u6709N\u4e2a\u7269\u54c1, \u6bcf\u4e2a\u7269\u54c1Cost\u4e3aC[i], Value\u4e3aW[i], \u5176\u4e2d i \u5c5e\u4e8e [0, &#8230;, N-1]\u6709\u4e00\u4e2a\u4e66\u5305, \u5bb9\u91cf\u4e3aV\u6c42\u4e66\u5305\u80fd\u88c5\u4e0b\u7684\u6700\u5927Value \u4e3a\u4ec0\u4e48\u53eb0-1\u80cc\u5305?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\" \/>\n<meta property=\"og:site_name\" content=\"Feel Like Learning\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-12T05:40:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-17T01:35:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/feellikelearning.com\/wp-content\/uploads\/2020\/12\/knapsack-python-cover.001.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#article\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\"},\"author\":{\"name\":\"feellikelearning\",\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"headline\":\"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 &#8211; 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm &#8211; 0-1 knapsack problem explained in Python\",\"datePublished\":\"2020-12-12T05:40:55+00:00\",\"dateModified\":\"2020-12-17T01:35:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\"},\"wordCount\":86,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a\"},\"articleSection\":[\"0-1 \u80cc\u5305\",\"Python\",\"\u52a8\u6001\u89c4\u5212\",\"\u7b97\u6cd5\",\"\u7f16\u7a0b\",\"\u80cc\u5305\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\",\"url\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\",\"name\":\"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | Feel Like Learning\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/#website\"},\"datePublished\":\"2020-12-12T05:40:55+00:00\",\"dateModified\":\"2020-12-17T01:35:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/feellikelearning.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 &#8211; 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm &#8211; 0-1 knapsack problem explained in Python\"}]},{\"@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":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | 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\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant","og_locale":"en_US","og_type":"article","og_title":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | Feel Like Learning","og_description":"\u95ee\u9898\u63cf\u8ff0 \u6709N\u4e2a\u7269\u54c1, \u6bcf\u4e2a\u7269\u54c1Cost\u4e3aC[i], Value\u4e3aW[i], \u5176\u4e2d i \u5c5e\u4e8e [0, &#8230;, N-1]\u6709\u4e00\u4e2a\u4e66\u5305, \u5bb9\u91cf\u4e3aV\u6c42\u4e66\u5305\u80fd\u88c5\u4e0b\u7684\u6700\u5927Value \u4e3a\u4ec0\u4e48\u53eb0-1\u80cc\u5305?","og_url":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant","og_site_name":"Feel Like Learning","article_published_time":"2020-12-12T05:40:55+00:00","article_modified_time":"2020-12-17T01:35:50+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/feellikelearning.com\/wp-content\/uploads\/2020\/12\/knapsack-python-cover.001.jpeg","type":"image\/jpeg"}],"author":"feellikelearning","twitter_card":"summary_large_image","twitter_misc":{"Written by":"feellikelearning","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#article","isPartOf":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant"},"author":{"name":"feellikelearning","@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"headline":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 &#8211; 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm &#8211; 0-1 knapsack problem explained in Python","datePublished":"2020-12-12T05:40:55+00:00","dateModified":"2020-12-17T01:35:50+00:00","mainEntityOfPage":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant"},"wordCount":86,"commentCount":0,"publisher":{"@id":"https:\/\/feellikelearning.com\/#\/schema\/person\/91fb815bebebf166c217b5e3764d437a"},"articleSection":["0-1 \u80cc\u5305","Python","\u52a8\u6001\u89c4\u5212","\u7b97\u6cd5","\u7f16\u7a0b","\u80cc\u5305"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#respond"]}]},{"@type":"WebPage","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant","url":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant","name":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 - 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm - 0-1 knapsack problem explained in Python | Feel Like Learning","isPartOf":{"@id":"https:\/\/feellikelearning.com\/#website"},"datePublished":"2020-12-12T05:40:55+00:00","dateModified":"2020-12-17T01:35:50+00:00","breadcrumb":{"@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/feellikelearning.com\/index.php\/2020\/12\/12\/cn-dynamic-programming-algorithm-0-1-knapsack-problem-explained-in-python\/?variant=zh-hant#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/feellikelearning.com\/"},{"@type":"ListItem","position":2,"name":"\u52a8\u6001\u89c4\u5212\u7b97\u6cd5 &#8211; 0-1 \u80cc\u5305\u95ee\u9898 Python \u8bb2\u89e3| Dynamic Programming Algorithm &#8211; 0-1 knapsack problem explained in Python"}]},{"@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\/962"}],"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=962"}],"version-history":[{"count":25,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/962\/revisions"}],"predecessor-version":[{"id":1029,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/posts\/962\/revisions\/1029"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/media\/1027"}],"wp:attachment":[{"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/media?parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/categories?post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feellikelearning.com\/index.php\/wp-json\/wp\/v2\/tags?post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}