26. Remove Duplicates from Sorted Array
来源:互联网 发布:辽宁省人工智能协会 编辑:程序博客网 时间:2024/05/07 06:15
class Solution {public: int removeDuplicates(vector<int>& nums) { if(0 != nums.size()) nums.push_back(nums.back() + 1); int ans = 0, sz = nums.size(), last = 0; for(int i = 0; i < sz-1; ++i){ nums[ans] = nums[i]; while(i < sz-1 && nums[i] == nums[i+1]) ++i; ++ans; } int t = nums.size() - ans; for(int i = 0; i < t; ++i) nums.pop_back(); return ans; }};
阅读全文
0 0
- [LeetCode]26.Remove Duplicates from Sorted Array
- 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
- 26. Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array
- 【leetcode】26. Remove Duplicates from Sorted Array
- 【leetcode】 26. Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array
- [leetCode]26. Remove Duplicates from Sorted Array
- LeetCode 26.Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array LeetCode
- 26. Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array
- 26. Remove Duplicates from Sorted Array
- CSU
- 2350: 彩排(二进制记录个数)
- QLabel 用法总结
- A. Jeff and Rounding----思维题
- Docker实战系列——第三话--docker 监控(三)-- how could we monitoring(1)?
- 26. Remove Duplicates from Sorted Array
- 为集合类型的属性注值
- CSU-1567-Reverse Rot
- POJ 2431 Expedition (优先队列 + 贪心)
- java访问zookeeper的增删改查
- Android 开发中几个实用的adb命令
- 【设计模式】代理模式
- Redis Sentinel 安装部署
- log4j-NDC和MDC