{"id":3215,"date":"2023-10-22T12:06:27","date_gmt":"2023-10-22T04:06:27","guid":{"rendered":"https:\/\/white-night.club\/?p=3215"},"modified":"2023-11-09T11:07:47","modified_gmt":"2023-11-09T03:07:47","slug":"ad85","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/22\/ad85\/","title":{"rendered":"\u524d\u7f00\u548c\uff1a\u5dee\u5206\u6570\u7ec4"},"content":{"rendered":"\n<p>\u4e86\u89e3\u4ec0\u4e48\u662f\u5dee\u5206\u6570\u7ec4\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u4e3a\u4ec0\u4e48\u8981\u7528\u5dee\u5206\u6570\u7ec4<\/p>\n<cite><em>\u533a\u95f4[a,b]\u5185\u8986\u76d6\u4e86n\u4e2a\u6570<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u653e\u4e2a\u4f8b\u9898\u65b9\u4fbf\u7406\u89e3\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/leetcode.cn\/problems\/points-that-intersect-with-cars\/\" target=\"_blank\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0086ff\" class=\"has-inline-color\">2848.\u00a0\u4e0e\u8f66\u76f8\u4ea4\u7684\u70b9<\/mark><\/a><\/p>\n\n\n\n<p>\u5148\u6765\u8bf4\u8bf4\u4e3a\u4ec0\u4e48\u8981\u7528\u5dee\u5206\u6570\u7ec4\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>\u5047\u8bbe\u7ed9\u5b9a\u5b58\u653e\u7740n\u4e2a\u533a\u95f4[a,b]\u7684\u6570\u7ec4\uff0c\u73b0\u5728\u8981\u7edf\u8ba1\u8fd9\u5728n\u4e2a\u533a\u95f4\u4e00\u5171\u51fa\u73b0\u4e86\u591a\u5c11\u4e2a\u6570\u3002<\/em><\/strong><\/p>\n\n\n\n<p>\u6bd4\u5982\u7ed9\u4e86\u4e00\u4e2a\u6570\u7ec4<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>[1,2],[2,2],[1,3],[6,9]<\/em><\/strong><\/p>\n\n\n\n<p>\u90a3\u4e48\u8be5\u533a\u95f4\u5185\u4e00\u5171\u51fa\u73b0\u4e86\u4ee5\u4e0b\u8fd9\u51e0\u4e2a\u6570\uff0c\u8fd9\u91cc\u4e00\u5171\u662f7\u4e2a\u6570<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>1,2,3,6,7,8,9<\/em><\/strong><\/p>\n\n\n\n<p>\u90a3\u600e\u4e48\u6c42\u5462\uff1f\u5982\u679c\u76f4\u63a5\u66b4\u529b\u7684\u8bdd\u601d\u8def\u53ef\u4ee5\u662f<\/p>\n\n\n\n<ul>\n<li>\u65b0\u5efa\u4e00\u4e2a\u6570\u7ec4result\u7528\u6765\u7ef4\u62a4\u51fa\u73b0\u8fc7\u7684\u503c\u3002\u518d\u904d\u5386\u6bcf\u4e00\u4e2a\u533a\u95f4\uff0c\u6bcf\u51fa\u73b0\u8fc7\u4e00\u6b21\u5c31\u66f4\u65b0\u4e00\u6b21result\uff0c\u6700\u540e\u518d\u5bf9result\u6570\u7ec4\u8fdb\u884c\u7edf\u8ba1\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5bf9\u4e8e\u4e0a\u9762\u4f8b\u5b50\u4e2d\u7684[1,2]\u548c[1,3]\uff0c\u5982\u679c\u7528\u66b4\u529b\u65b9\u6cd5\u7684\u8bdd[1,2]\u533a\u95f4\u5c31\u4f1a\u88ab\u904d\u5386\u4e24\u6b21\u3002\u5982\u679c\u628a[1,2]\u6539\u4e3a[1,999999]\uff0c\u90a3\u6548\u7387\u5c06\u4f1a\u4f4e\u7684\u60ca\u4eba\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u6211\u4eec\u5f15\u5165\u4e86\u201c\u5dee\u5206\u6570\u7ec4\u201d\uff0c\u7528\u4e8e\u7ef4\u62a40-n\u533a\u95f4\u6bcf\u4e2a\u6570\u5728\u5bf9\u5e94\u533a\u95f4\u51fa\u73b0\u7684\u6b21\u6570\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u4ec0\u4e48\u662f\u5dee\u5206\u6570\u7ec4<\/p>\n<cite><em>diff[left] &#8211; diff[right+1]\u533a\u95f4\u7684\u524d\u7f00\u548c<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5bf9\u4e8e\u4e0a\u9762\u7684\u4f8b\u5b50<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><em>[1,2],[2,2],[1,3],[6,9]<\/em><\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u65b0\u5efa\u4e00\u4e2a\u6570\u7ec4diff\uff0c\u6570\u7ec4\u5927\u5c0f\u4e3a11\uff080-10\uff09,\u5e76\u521d\u59cb\u5316\u503c\u4e3a0\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e[1,2]\uff0c\u6211\u4eec\u4ee4diff[1]+=1\uff0cdiff[2+1]-=1\u3002\u5b83\u8868\u793a\u201c1\u201d\u4f5c\u4e3a\u5de6\u533a\u95f4\u503c\u51fa\u73b0\u4e86\u4e00\u6b21\uff0c\u800c3\u6ca1\u6709\u5728\u533a\u95f4\u5185\u51fa\u73b0\u3002\u90a3\u4e48\u6b64\u65f6\u5bf9diff\u7684\u6bcf\u4e00\u9879\u6c42\u548c\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u5f53diff[x]\u7684\u548c\u5927\u4e8e0\u65f6\uff0c\u8868\u793ax\u5b58\u5728\u4e8e\u533a\u95f4\u4e2d<\/mark>\u3002\u5982\u679c\u67d0\u4e2a\u65f6\u523b\u524d\u7f00\u548c\u7b49\u4e8e0\u6216\u8005\u5c0f\u4e8e0\uff0c\u5219\u8868\u793a\u6b64\u65f6\u7684x\u4e0d\u5b58\u5728\u533a\u95f4\u4e2d\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e[2,2]\uff0cdiff[2]+=1,diff[2+1]-=1\uff0c\u6b64\u65f6diff\u7684\u6570\u636e\u5982\u4e0b<\/p>\n\n\n\n<ul>\n<li>diff[0]=0<\/li>\n\n\n\n<li>diff[1]=1<\/li>\n\n\n\n<li>diff[2]=1<\/li>\n\n\n\n<li>diff[3]=-2<\/li>\n\n\n\n<li>diff[4]=0<\/li>\n<\/ul>\n\n\n\n<p>\u5bf9\u4e8e[1,3]\uff0cdiff[1]+=1,diff[3+1]-=1\uff0c\u6b64\u65f6diff\u5982\u4e0b<\/p>\n\n\n\n<ul>\n<li>diff[0]=0<\/li>\n\n\n\n<li>diff[1]=2<\/li>\n\n\n\n<li>diff[2]=1<\/li>\n\n\n\n<li>diff[3]=-2<\/li>\n\n\n\n<li>diff[4]=-1<\/li>\n<\/ul>\n\n\n\n<p>\u6b64\u65f6\u5bf9diff\u6c42\u524d\u7f00\u548c\u3002<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">sum(diff[1])=2>0\uff0c\u6240\u4ee51\u51fa\u73b0\u5728\u533a\u95f4\u4e2d\uff1bsum(diff[2])=3>0\uff0c\u6240\u4ee52\u51fa\u73b0\u5728\u533a\u95f4\u4e2d\uff1bsum(diff[3])=1>0\uff0c\u6240\u4ee53\u51fa\u73b0\u5728\u533a\u95f4\u4e2d\uff1bsum(diff[4])=0\uff0c\u6240\u4ee54\u4e0d\u5728\u533a\u95f4\u4e2d\u3002<\/mark><\/p>\n\n\n\n<p>\u4ee5\u6b64\u7c7b\u63a8\uff0c\u90a3\u4e48\u6700\u540e\u5bf9diff\u7684\u6bcf\u4e00\u9879\u6c42\u548c\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u533a\u95f4\u5185\u51fa\u73b0\u4e86\u591a\u5c11\u4e2a\u6570\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u8fd9\u5757\u6709\u70b9\u201d\u53ea\u53ef\u610f\u4f1a\u4e0d\u53ef\u8a00\u4f20\u201c\u7684\u610f\u601d\u3002\u6211\u53cd\u6b63\u770b\u522b\u4eba\u7684\u601d\u8def\u662f\u6ca1\u770b\u61c2\uff0c\u6700\u540e\u81ea\u5df1\u4e0a\u624b\u5199\u4e86\u4e0b\u4f8b\u9898\u624d\u641e\u61c2\u4e3a\u5565\u8981\u7528\u5dee\u5206\u6570\u7ec4diff\u3002\u800c\u4e14\u611f\u89c9\u8fd9\u79cd\u9898\u53ef\u80fd\u6709\u5f88\u591a\u53d8\u5f62\u554a\uff0c\u56e0\u4e3a\u6700\u540e\u6c42\u524d\u7f00\u548c\u662f\u5bf9\u6574\u4e2adiff\u6570\u7ec4\u6c42\uff0c\u4e4b\u540e\u518d\u770b\u770b\u80fd\u4e0d\u80fd\u78b0\u5230\u53d8\u5f62\u9898\u7ec3\u7ec3\u624b\u3002<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u7406\u89e3\u4ec0\u4e48\u662f\u5dee\u5206\u6570\u7ec4<\/p>\n","protected":false},"author":1,"featured_media":3220,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[25,50],"tags":[103,36],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3215"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=3215"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3215\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/3220"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=3215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}