###### 【Leet Code】26. Remove Duplicates from Sorted Array---Easy

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.

class Solution {
public:
int removeDuplicates(int A[], int n) {
if(n <= 0) return 0;
int j = 0, i = 1;
while(i < n)
{
while(A[i] == A[j]) i++;
if(i < n)
{
j++;
A[j] = A[i];
}
}
return j+1;
}
};

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

2015-07-28 12:36:07

#### Leetcode_26_Remove Duplicates from Sorted Array

2014-11-27 23:21:40

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

2014-02-23 15:12:20

#### 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

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

2014-02-27 05:12:22

#### 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

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

2015-02-02 11:52:37

## 不良信息举报

【Leet Code】26. Remove Duplicates from Sorted Array---Easy