Remove Duplicates from Sorted Array II
来源:互联网 发布:aim聊天软件 编辑:程序博客网 时间:2024/06/05 17:28
/*2017.10.7//LeedCode : Remove Duplicates from Sorted Array II 需要一个计数器,如果重复次数小于2,就把这个元素放到新数组里.*/int removeDuplicates(int* nums, int numsSize) { int k = 0, i, cnt = 1;; if(numsSize == 0) return numsSize; for(i = 1; i < numsSize; i++){ if(nums[k] == nums[i]){ cnt++; if(cnt == 2) nums[++k] = nums[i]; }else{ cnt = 1; nums[++k] = nums[i]; } } return k+1;}原题链接
阅读全文
0 0
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- [leetcode] Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- Remove duplicates from sorted array II
- Remove Duplicates from Sorted Array II
- [LeetCode]Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted Array II
- LeetCode-Remove Duplicates from Sorted Array II
- Hive内部表与外部表(外部表使用场景)
- POJ 1573--Robot Motion
- 【STM32小案例 06 】STM32使用按键驱动L298N电机模块控制电机正反转
- HDU1166 敌兵布阵
- 学习JavaScript数据结构与算法(四)——循环链表
- Remove Duplicates from Sorted Array II
- 看起来像它——图像搜索其实也不难
- 标准IO缓存
- js 时间-date
- 一些oracle相关的链接
- company
- 循环,数组,参数变量
- HDU1556 Color the ball
- java实现线性表中的链式存储