Remove Duplicates from Sorted Array II
来源:互联网 发布:淘宝优惠券显示不了 编辑:程序博客网 时间:2024/05/01 08:11
描述
Follow up for ”Remove Duplicates”: What if duplicates are allowed at most twice?
For example, Given sorted array A = [1,1,1,2,2,3],
Your function should return length = 5, and A is now [1,1,2,2,3]
int del2Dumplicate(int arr[], int len){if (len == 0){return 0;}int occur = 1;int index = 0;for (int i = 1; i < len; i++) {if (arr[index] == arr[i]) {if (occur < 2) {arr[++index] = arr[i];occur++;}} else {arr[++index] = arr[i];occur = 1;}}return index + 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
- usaco training 5.3.3 Network of Schools 题解
- HashMap和Hashtable的区别
- myan回复几个问题
- Java NIO的多路复用及reactor
- 《使用Python进行自然语言处理》学习笔记五
- Remove Duplicates from Sorted Array II
- Ubuntu虚拟机安装
- Android开发中 页面加载超大图片时出现OOM
- LeetCode Pascal's Triangle
- 地铁换乘
- linux 驱动学习-1th
- apue和unp的学习之旅01——网络基本概念
- IOS中的随机数arc4random方法
- mysql删除,插入,查询等语句的总结