Leetcode Problem.26—Remove Duplicates from Sorted Array
来源:互联网 发布:linux 进程逻辑地址 编辑:程序博客网 时间:2024/06/06 05:28
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.
My C++ solution!
int removeDuplicates(vector<int>& nums) { int len=nums.size();if(len==0)return 0;vector<int>::iterator it=nums.begin();while(it!=nums.end()-1){if(*it==*(it+1))it=nums.erase(it);elseit++;}return nums.size(); }
0 0
- Leetcode Problem.26—Remove Duplicates from Sorted Array
- 【Leetcode Problem 26】之Remove Duplicates from Sorted Array
- LeetCode(26)Remove Duplicates From Sorted Array
- [leetcode 26] Remove Duplicates from Sorted Array
- [Leetcode] 26 - Remove Duplicates from Sorted Array
- leetcode|26|Remove Duplicates from Sorted Array
- leetcode-26 Remove Duplicates from Sorted Array
- leetcode 26 Remove Duplicates from Sorted Array
- LeetCode 26 Remove Duplicates from Sorted Array
- LeetCode 26 Remove Duplicates from Sorted Array
- LeetCode 26 Remove Duplicates from Sorted Array
- leetcode 26 Remove Duplicates from Sorted Array
- LeetCode---(26) Remove Duplicates from Sorted Array
- Leetcode 26 Remove Duplicates from Sorted Array
- LeetCode 26 - Remove Duplicates from Sorted Array
- Leetcode[26]-Remove Duplicates from Sorted Array
- leetcode 26 -- Remove Duplicates from Sorted Array
- LeetCode 26: Remove Duplicates from Sorted Array
- IOS多语言环境自由切换
- 夜维执行慢的原因探究
- iptables 初探
- Leetcode Problem.21—Merge Two Sorted Lists
- java DelayQueue 延期队列 21.7.3 -------thinking java 4
- Leetcode Problem.26—Remove Duplicates from Sorted Array
- Linux下php安装zlib扩展
- HDU 5265 序列变换 —— 最长不降子序列
- 编程之思考
- SQL Server数据库添加100条数据
- 证明SJF(Shortest Job First:最短作业优先算法)策略生成的调度方案理论最优
- Leetcode Problem.27—Remove Element
- iis发布网站,网站访问地址
- delphi ocx在IE8下调试不能断点的问题