{"id":286345,"date":"2021-01-16T23:00:06","date_gmt":"2021-01-16T15:00:06","guid":{"rendered":"http:\/\/4563.org\/?p=286345"},"modified":"2021-01-16T23:00:06","modified_gmt":"2021-01-16T15:00:06","slug":"%e8%b0%b7%e6%ad%8c%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9a%e5%88%a0%e9%99%a4%e6%8e%92%e5%ba%8f%e6%95%b0%e7%bb%84%e4%b8%ad%e7%9a%84%e9%87%8d%e5%a4%8d%e6%95%b0%e5%ad%97","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=286345","title":{"rendered":"\u8c37\u6b4c\u9762\u8bd5\u9898\uff1a\u5220\u9664\u6392\u5e8f\u6570\u7ec4\u4e2d\u7684\u91cd\u590d\u6570\u5b57"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8c37\u6b4c\u9762\u8bd5\u9898\uff1a\u5220\u9664\u6392\u5e8f\u6570\u7ec4\u4e2d\u7684\u91cd\u590d\u6570\u5b57               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u63cf\u8ff0<\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6392\u5e8f\u6570\u7ec4\uff0c\u5728\u539f\u6570\u7ec4\u4e2d\u201c\u5220\u9664\u201d\u91cd\u590d\u51fa\u73b0\u7684\u6570\u5b57\uff0c\u4f7f\u5f97\u6bcf\u4e2a\u5143\u7d20\u53ea\u51fa\u73b0\u4e00\u6b21\uff0c\u5e76\u4e14\u8fd4\u56de\u201c\u65b0\u201d\u6570\u7ec4\u7684\u957f\u5ea6\u3002 \u4e0d\u8981\u4f7f\u7528\u989d\u5916\u7684\u6570\u7ec4\u7a7a\u95f4\uff0c\u5fc5\u987b\u5728\u4e0d\u4f7f\u7528\u989d\u5916\u7a7a\u95f4\u7684\u6761\u4ef6\u4e0b\u539f\u5730\u5b8c\u6210\u3002<\/p>\n<p>\u5728\u7ebf\u8bc4\u6d4b\u5730\u5740<\/p>\n<h3>\u6837\u4f8b 1<\/h3>\n<pre><code>\u8f93\u5165:  [] \u8f93\u51fa: 0 <\/code><\/pre>\n<h3>\u6837\u4f8b 2<\/h3>\n<pre><code>\u8f93\u5165:  [1,1,2] \u8f93\u51fa: 2         \u89e3\u91ca:  \u6570\u5b57\u53ea\u51fa\u73b0\u4e00\u6b21\u7684\u6570\u7ec4\u4e3a: [1,2] <\/code><\/pre>\n<p>\u7b97\u6cd5\uff1a\u53cc\u6307\u9488<\/p>\n<h3>\u7b97\u6cd5\u601d\u8def<\/h3>\n<ul>\n<li>Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.<\/li>\n<li>Do not allocate extra space for another array, you must do this in place with constant memory.<\/li>\n<li>For example, Given input array A = 1,1,2,<\/li>\n<li>Your function should return length = 2, and A is now 1,2.<\/li>\n<li>\u7531\u4e8e\u6709\u5e8f\uff0c\u6240\u4ee5\u76f8\u540c\u7684\u6570\u5b57\u6392\u5728\u4e00\u8d77\u3002 \u7528\u4e00\u4e2a\u6e38\u6807\u53d8\u91cf\u6307\u5411\u5df2\u7ecf\u53bb\u91cd\u7684\u90e8\u5206\u7684\u4e0b\u4e00\u4e2a\u7a7a\u4f4d\uff0c\u53ea\u8981 a[i]!=a[i\u22121]a[i]!=a[i\u22121],\u5c31\u5c06 ai \u586b\u5165\u4e4b\u524d\u7684\u7a7a\u4f4d\u3002<\/li>\n<\/ul>\n<pre><code>public class Solution {     public int removeDuplicates(int[] A) {         if (A == null || A.length == 0) {             return 0;         }                  int size = 0;         for (int i = 0; i &lt; A.length; i++) {             if (A[i] != A[size]) {                 A[++size] = A[i];             }         }         return size + 1;     } } <\/code><\/pre>\n<p>\u66f4\u591a\u9898\u89e3\u53c2\u8003<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8c37\u6b4c\u9762\u8bd5\u9898\uff1a\u5220\u9664\u6392\u5e8f\u6570\u7ec4\u4e2d\u7684\u91cd\u590d\u6570&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\/286345"}],"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=286345"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/286345\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}