【LeetCode】Remove Duplicates from Sorted Array
来源:互联网 发布:windows版本怎么升级 编辑:程序博客网 时间:2024/05/17 01:47
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 A = [1,1,2]
,
Your function should return length = 2
, and A is now [1,2]
.
class Solution {public: int removeDuplicates(int A[], int n) { int ret; int num=0; if(0 == n)return 0; for(int i=1;i<n;i++){ if(A[num] != A[i]){ A[++num]=A[i]; } } ret=num+1; while(num<n-1)A[++num]=0; return ret; }};
0 0
- [leetcode][array] Remove Duplicates from Sorted Array
- 【Leetcode】【Array】Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array
- [Leetcode] Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- leetcode 35: Remove Duplicates from Sorted Array
- [LeetCode] Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array
- Leetcode: Remove Duplicates from Sorted Array
- [leetcode] Remove Duplicates from Sorted Array II
- [LeetCode]Remove Duplicates from Sorted Array
- [LeetCode]Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted Array
- [leetcode]Remove Duplicates from Sorted Array II
- 发布网站
- swift user guide.pdf下载
- 自定义SeekBar
- 苹果编程语言Swift中文教程:Swift简介 地址
- Android canvas clip 参数解释
- 【LeetCode】Remove Duplicates from Sorted Array
- VM虚拟机里的Ubuntu系统怎么设置屏幕分辨率?
- android动态加载jar以及插件化开发
- C# 制作圆角label
- 爬虫-for fun
- 北京重点小学择校攻略1(转帖)
- [leetcode]Path Sum&&Path Sum II(剑指offer面试题25)
- SqlServer 不常用的语句记录
- 关于jquery的getjson的 unexpected token :