{"id":154313,"date":"2020-09-06T18:45:01","date_gmt":"2020-09-06T10:45:01","guid":{"rendered":"http:\/\/4563.org\/?p=154313"},"modified":"2020-09-06T18:45:01","modified_gmt":"2020-09-06T10:45:01","slug":"%e5%88%b7-leetcode-lintcode-%e7%9a%84%e4%b8%80%e4%ba%9b%e5%bf%83%e5%be%97","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=154313","title":{"rendered":"\u5237 LeetCode\/LintCode \u7684\u4e00\u4e9b\u5fc3\u5f97"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5237 LeetCode\/LintCode \u7684\u4e00\u4e9b\u5fc3\u5f97               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u4e4b\u524d\u5c31\u662f\u5b8c\u5168 0 \u57fa\u7840\u3001\u5927\u9f84\u8f6c\u7801\uff0c\u5237\u9898\u4e0a\u5343\u7136\u540e\u8fdb\u8c37\u6b4c\u7684\u2026\u2026<\/p>\n<p>\u8fd9\u91cc 0 \u57fa\u7840\u6307\u7684\u662f\u6ca1\u5b66\u8fc7\u7f16\u7a0b\u8bed\u8a00\uff0c\u6ca1\u5b66\u8fc7\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\uff0c\u4e00\u4e0a\u6765\u5c31\u76f4\u63a5\u505a\u9898\u90a3\u79cd\u3002<\/p>\n<p>\u7b2c\u4e00\u9053\u9898 two sum\uff0c\u6211\u663e\u7136\u4e0d\u4f1a\u505a\u3002**\u6211\u7684\u7b28\u65b9\u6cd5\u5c31\u662f\u770b\u7b54\u6848\uff0c\u80cc\u7b54\u6848\uff0c\u7136\u540e\u9ed8\u51fa\u6765\uff0c\u5c31\u8fd9\u6837\u8fd8\u662f\u9519\u4e86\u5f88\u591a\u6b21\u3002<\/p>\n<p>\u7136\u800c\u5c31\u662f\u8fd9\u6837\u4f4e\u7684\u8d77\u70b9\uff0c\u6211\u628a LC \u524d 300 \u9053\u9898\u5237\u4e86\u81f3\u5c11 3 \u904d\uff0c\u7d2f\u8ba1\u5237\u9898\u6570\u8d85\u8fc7 1000 \u9053\uff0c\u6700\u540e\u9760\u5237\u9898\u4e0a\u5cb8\u4e86\u8c37\u6b4c\u3002\uff08\u4e5f\u6709\u8fd0\u6c14\u7684\u6210\u5206\uff0c\u5f53\u65f6\u7b80\u5355\u591a\u4e86\uff09<\/p>\n<p>\u6211\u5e76\u4e0d\u9f13\u52b1\u5927\u5bb6\u4ece 0 \u5f00\u59cb\u5237\u9898\uff0c\u6bd5\u7adf\u6211\u771f\u7684\u8d70\u4e86\u5f88\u591a\u5f2f\u8def\uff0c\u8e29\u4e86\u65e0\u6570\u5751\u3002<\/p>\n<p>\u5982\u679c\u80fd\u65e9\u70b9\u638c\u63e1\u6b63\u786e\u7684\u65b9\u6cd5\uff0c\u6211\u5c31\u4e0d\u7528\u5237 1000 \u9053\u9898\u4e86\uff08\u867d\u7136\u7ed3\u679c\u662f\u597d\u7684\uff09\u3002<\/p>\n<p>\u5728Leetcode\/LintCode\u5f00\u59cb\u5237\u9898\uff0c\u9996\u5148\u6700\u597d\u80fd\u5177\u5907\u4e00\u5b9a\u7684\u57fa\u7840\uff0c\u5305\u62ec\uff1a \uff08\u8fd9\u91cc\u8bf4\u4e00\u4e0b\uff0c\u6211\u4e00\u5f00\u59cb\u662f\u7528\u7684 LeetCode \u3002\u9047\u4e0a LintCode \u6709\u6d3b\u52a8\uff0c\u4fbf\u5b9c\u4e86\u5c0f\u51e0\u767e\uff0c\u5c31\u8bd5\u7528\u4e86\u4e00\u4e0b\uff0c\u611f\u89c9\u529f\u80fd\u5dee\u4e0d\u591a\uff0c\u7ed9\u5927\u5bb6\u591a\u4e2a\u9009\u62e9\u5427\uff09<\/p>\n<h2>\u8bed\u8a00\u57fa\u7840<\/h2>\n<p>\u7528\u4e8e\u5237\u9898\u7684\u7f16\u7a0b\u8bed\u8a00\u6709\u5f88\u591a\uff0c\u7b97\u6cd5\u662f\u901a\u7528\u7684\uff0c\u4e0d\u53d7\u9650\u4e8e\u8bed\u8a00\uff0c\u4e3b\u6d41\u7684 Java \u6216\u8005 Python \u90fd\u53ef\u4ee5\u3002<\/p>\n<p>Java \u7684\u4f18\u70b9\u662f\u7528\u7684\u516c\u53f8\u591a\uff0c\u4e00\u822c\u9762\u8bd5\u5b98\u6ca1\u6709\u4e0d\u4f1a Java \u7684\uff1b Python \u4f18\u52bf\u5728\u4e8e\u8bed\u6cd5\u7b80\u5355\uff0ccoding \u80fd\u8282\u7701\u5f88\u591a\u65f6\u95f4\u3002<\/p>\n<h2>\u7b97\u6cd5\u90e8\u5206<\/h2>\n<pre><code>\u4e8c\u5206\u641c\u7d22 Binary Search  \u5206\u6cbb Divide Conquer  \u5bbd\u5ea6\u4f18\u5148\u641c\u7d22 Breadth First Search  \u6df1\u5ea6\u4f18\u5148\u641c\u7d22 Depth First Search \u56de\u6eaf\u6cd5 Backtracking  \u53cc\u6307\u9488 Two Pointers  \u52a8\u6001\u89c4\u5212 Dynamic Programming  \u626b\u63cf\u7ebf Scan-line algorithm \u5feb\u6392 Quick Sort <\/code><\/pre>\n<h2>\u6570\u636e\u7ed3\u6784\u90e8\u5206<\/h2>\n<pre><code>\u6808 Stack \u961f\u5217 Queue \u94fe\u8868 Linked List  \u6570\u7ec4 Array  \u54c8\u5e0c\u8868 Hash Table \u4e8c\u53c9\u6811 Binary Tree   \u5806 Heap \u5e76\u67e5\u96c6 Union Find \u5b57\u5178\u6811 Trie <\/code><\/pre>\n<p>\u5982\u679c\u662f\u5e94\u5bf9\u6c42\u804c\u9762\u8bd5\uff0c\u90a3\u4e48\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u7684\u9762\u8bd5\u9ad8\u9891\u77e5\u8bc6\u70b9\u6765\u5237\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e7ef2aaf90.png\" alt=\"\u5237 LeetCode\/LintCode \u7684\u4e00\u4e9b\u5fc3\u5f97\" \/><\/p>\n<p>\u5bf9\u7b97\u6cd5\u9898\u6765\u8bf4\u6709\u4e24\u5927\u6cd5\u5b9d\uff0c\u201c\u62ff\u5230\u9898\u9009\u4ec0\u4e48\u7b97\u6cd5\u201d\u548c\u201c\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e2a\u7b97\u6cd5\u201d\uff0c\u540e\u8005\u4f1a\u66f4\u5bb9\u6613\u4e00\u4e9b\uff0c\u6240\u4ee5\u53ef\u4ee5\u5148\u4ece\u5b9e\u73b0\u7b97\u6cd5\u5f00\u59cb\u7ec3\u8d77\u3002<\/p>\n<p><strong>\u5f53\u7136\uff0c\u9488\u5bf9\u9762\u8bd5\u7b97\u6cd5\uff0c\u4e5f\u6709\u4e00\u4e9b\u4e66\uff1a<\/strong><\/p>\n<p><strong>\u300a\u5251\u6307 Offer \u300b<\/strong>\uff1a\u51e0\u4e4e\u5305\u542b\u6240\u6709\u5e38\u89c1\u7684\u3001\u7ecf\u5178\u7684\u9762\u8bd5\u9898\uff0c\u662f\u5e94\u5bf9\u9762\u8bd5\u7684\u5fc5\u8bfb\u4e66\u7c4d<\/p>\n<p><strong>\u300a\u7f16\u7a0b\u4e4b\u7f8e\u300b<\/strong>\uff1a\u9002\u5408\u51c6\u5907\u9762\u8bd5 FLAG \u5927\u5382\u65f6\u5019\u7528\u6765\u5237\u9898<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200913_5f5e7ef8cac67.jpg\" alt=\"\u5237 LeetCode\/LintCode \u7684\u4e00\u4e9b\u5fc3\u5f97\" \/><\/p>\n<h1>\u6700\u540e\uff0c\u5173\u4e8e\u7b97\u6cd5\u548c\u6570\u636e\u7ed3\u6784\uff0c\u518d\u63a8\u8350\u4e00\u4e9b\u4e66\u3002<\/h1>\n<p> <\/p>\n<h2>1.\u5165\u95e8\u7cfb\u5217\uff1a<\/h2>\n<p><strong>\u300a\u7b97\u6cd5\u56fe\u89e3\u300b<\/strong>\uff1a\u201c\u50cf\u5c0f\u8bf4\u4e00\u6837\u6709\u8da3\u7684\u7b97\u6cd5\u5165\u95e8\u4e66\u201d\uff0c\u4e3b\u6253\u201c\u56fe\u89e3\u201d\uff0c\u901a\u4fd7\u6613\u61c2<\/p>\n<p><strong>\u300a\u5927\u8bdd\u6570\u636e\u7ed3\u6784\u300b<\/strong>\uff1a\u628a\u7406\u8bba\u8bb2\u5f97\u6709\u8da3\u4e0d\u67af\u71e5\uff1b\u6bcf\u4e2a\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\uff0c\u4f5c\u8005\u90fd\u7ed3\u5408\u4e86\u751f\u6d3b\u4e2d\u7684\u4f8b\u5b50\uff0c\u80fd\u8ba9\u4f60\u6709\u975e\u5e38\u76f4\u89c2\u7684\u611f\u53d7\u3002<\/p>\n<h2>2.\u6559\u79d1\u4e66\u7cfb\u5217\uff1a<\/h2>\n<p><strong>\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u5206\u6790\u300b<\/strong>\uff1a\u5f88\u591a\u5927\u5b66\u90fd\u62ff\u5b83\u5f53\u4f5c\u6559\u6750\uff0c\u975e\u5e38\u7cfb\u7edf\u3001\u5168\u9762\u3001\u4e25\u8c28\uff0c\u9002\u5408\u638c\u63e1\u4e86\u81f3\u5c11\u4e00\u95e8\u7f16\u7a0b\u8bed\u8a00\u7684\u540c\u5b66\u3002<\/p>\n<p>\u4f5c\u8005\u4e5f\u5f88\u8d34\u5fc3\uff0c\u8fd9\u672c\u4e66\u6709\u4e09\u79cd\u8bed\u8a00\u7684\u7248\u672c\uff1a\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u5206\u6790 : C \u8bed\u8a00\u63cf\u8ff0\u300b\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u5206\u6790 : C++ \u63cf\u8ff0\u300b\u300a\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u5206\u6790 : Java \u8bed\u8a00\u63cf\u8ff0\u300b\u3002<\/p>\n<h2>3.\u8fdb\u9636\u4e4b\u65c5\uff1a<\/h2>\n<p><strong>\u300a\u7b97\u6cd5\u5bfc\u8bba\u300b<\/strong>\uff1a\u6709\u4e86\u4e00\u5b9a\u57fa\u7840\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u5543\u8fd9\u672c\u5927\u90e8\u5934\u4e86\u3002<\/p>\n<h2>4.\u6269\u5c55\u9605\u8bfb\uff1a<\/h2>\n<p><strong>\u300a\u7b97\u6cd5\u4e4b\u7f8e\u300b<\/strong>\uff1a\u7b97\u6cd5\u79d1\u666e\uff0c\u4ece\u751f\u6d3b\u4e2d\u7684\u5404\u79cd\u95ee\u9898\u8bf4\u8d77\uff1a\u79df\u623f\u3001\u8c08\u604b\u7231\u3001\u8001\u864e\u673a\u3001\u62cd\u7535\u5f71\u3001\u9762\u8bd5\u3001\u4e70\u5f69\u7968\u3001\u5404\u79cd\u6392\u5e8f\u3001\u627e\u505c\u8f66\u4f4d\u3001\u5bfb\u627e\u65b0\u836f\u3001\u4e34\u5e8a\u8bd5\u9a8c\u3001\u5965\u5df4\u9a6c\u62c9\u8d5e\u52a9\u3001\u9884\u4f30\u7535\u5f71\u7968\u623f\u7b49\u7b49\uff0c\u975e\u5e38\u751f\u6d3b\u5316\uff0c\u53ef\u4ee5\u4f5c\u4e3a\u8865\u5145\u9605\u8bfb\u3002<\/p>\n<p><strong>\u300a\u7b97\u6cd5\u5e1d\u56fd\u300b<\/strong>\uff1a\u540c\u6837\u662f\u79d1\u666e\u7c7b\u4e66\u7c4d\uff0c\u5e76\u65e0\u6d89\u53ca\u7b97\u6cd5\u7684\u539f\u7406\u4e0e\u5b9e\u73b0\u7ec6\u8282\uff0c\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u8865\u5145\u9605\u8bfb\u3002<\/p>\n<h2>5.\u6bbf\u5802\u7ea7<\/h2>\n<p>\u300a\u8ba1\u7b97\u673a\u7a0b\u5e8f\u8bbe\u8ba1\u827a\u672f\u300b\uff1a\u5305\u542b\u5f88\u591a\u5377\uff0c\u6df1\u5ea6\u3001\u5e7f\u5ea6\u3001\u7cfb\u7edf\u6027\u3001\u5168\u9762\u6027\u662f\u5176\u4ed6\u6240\u6709\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u4e66\u7c4d\u90fd\u6240\u65e0\u6cd5\u76f8\u6bd4\u3002\u53ef\u4ee5\u5f53\u505a\u4e00\u79cd\u6311\u6218~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3242797\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : scofieldpeng <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u8c22\u5206\u4eab                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3242798\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Chry3anthemum <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u8c22\u5206\u4eab\uff0c\u867d\u7136\u662f\u641e\u534a\u5bfc\u4f53\u7684\uff0c\u4e5f\u51c6\u5907\u5237\u7b97\u6cd5\u4e86\uff0c\u6253\u6e38\u620f\u6d6a\u8d39\u7684\u65f6\u95f4\u6709\u70b9\u591a\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5237 LeetCode\/LintCo&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154313"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154313"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154313\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154313"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}