Android大法好！！

# leetCode 26.Remove Duplicates from Sorted Array(删除数组重复点) 解题思路和方法

Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

Do not allocate extra space for another array, you must do this in place with constant memory.

For example,
Given input array nums = [1,1,2],

Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length.

public class Solution {
public int removeDuplicates(int[] nums) {
if(nums.length <= 1){
return nums.length;
}
int len = 1;//新的长度，至少为1,以下循环从i=1开始
for(int i = 1; i < nums.length; i++){
if(nums[i] != nums[i-1]){//不等于前一个元素，长度+1
nums[len++] = nums[i];//将新的元素装到前len个
}
}
return len;
}
}

#### 【LeetCode-面试算法经典-Java实现】【026-Remove Duplicates from Sorted Array（删除排序数组中的重复元素）】

2015-07-24 07:01:05

#### LeetCode-26 Remove Duplicates from Sorted Array(水题-去相同元素)

2015-04-29 17:29:39

#### [leetcode]Remove Duplicates from Sorted List (删除有序节点的值重复的节点 C语言)

2015-03-28 18:17:40

#### Remove Duplicates from Sorted Array II 从有序数组里移除重复出现元素，最多重复出现2次 @LeetCode

2013-10-20 12:55:08

#### Remove Duplicates from Sorted Array II -- LeetCode

2014-04-23 08:39:29

#### LeetCode 26 — Remove Duplicates from Sorted Array（C++ Java Python）

2014-02-23 15:12:20

#### [C++]LeetCode 26: Remove Duplicates from Sorted Array（有序数组去重）

2015-05-02 21:43:54

#### Remove Duplicates from Sorted Array -- LeetCode

2014-02-27 05:12:22

#### leetCode 80.Remove Duplicates from Sorted Array II (删除排序数组中的重复II) 解题思路和方法

2015-07-22 13:25:06

#### [leetcode-26]Remove Duplicates from Sorted Array(C)

2015-07-28 12:36:07