80. Remove Duplicates from Sorted Array II
来源:互联网 发布:高性能mysql怎么样 编辑:程序博客网 时间:2024/06/03 19:46
class Solution {public: int removeDuplicates(vector<int>& nums) { int n=nums.size(); int k=0; int cnt=1; sort(nums.begin(),nums.end()); for(int i=1;i<n;i++) { if(nums[i]==nums[i-1]) { cnt++; if(cnt>=3) k++; else nums[i-k]=nums[i]; } else { cnt=1; nums[i-k]=nums[i]; } } return n-k; }};
0 0
- 80. Remove Duplicates from Sorted Array II
- 80.Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- 80. Remove Duplicates from Sorted Array II
- Integer类型的对象相等的问题
- Redis的使用
- jQuery的选择器
- 面向对象设计原则之四:依赖倒置原则
- jQuery四种事件绑定
- 80. Remove Duplicates from Sorted Array II
- js操作节点
- js类操作
- 使用Eclipse构建Maven项目(转)
- js与jQuery入一些区别
- LOKI:一款APT威胁指标扫描软件
- Linux下创建、扩展、移除、管理LVM
- 词法作用域(!!!重点)
- 详解 CSS 属性:伪类和伪元素的区别