###### Easy-题目29：26. 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[] A) {
int len = A.length;
if (len == 0)
return 0;
int count = 1;
for (int i = 1; i < len; i++) {
if (A[i] != A[i - 1])
A[count++] = A[i];
}
return count;
}
}

1ms,beats 54.30%,众数2ms,46.31%
cmershen的碎碎念：

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

2015-07-28 12:36:07

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

2014-02-23 15:12:20

#### Leetcode_26_Remove Duplicates from Sorted Array

2014-11-27 23:21:40

#### 26. Remove Duplicates from Sorted Array-Python

2017-07-05 21:39:13

#### 26. Remove Duplicates from Sorted Array (python)

2016-10-30 15:58:23

#### LeetCode Remove Duplicates from Sorted Array(C语言O(n)解法)

2015-03-10 15:03:38

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

2015-04-29 17:29:39

#### [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 --- 26. Remove Duplicates from Sorted Array

2015-02-02 11:52:37

## 不良信息举报

Easy-题目29：26. Remove Duplicates from Sorted Array