Remove Duplicates from Sorted Array
来源:互联网 发布:csdn知乎 编辑:程序博客网 时间:2024/05/11 04:51
描述
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 A = [1,1,2],
Your function should return length = 2, and A is now [1,2].
链接地址:
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/
code:
int A[]={2,2,3,3,3,5,5,5,5}; int n=9; int cur=0; for (int i=1; i<n;i++) { if (A[i]!=A[cur]) { cur++; A[cur]=A[i]; } } for (int i=0; i<=cur; i++) { cout<<A[i]<<" "; } cout<<cur+1<<endl;
0 0
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates From Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- Remove Duplicates from Sorted Array
- CMake使用教程
- 仿射函数和仿射组合
- HDU 1087 Super Jumping! Jumping! Jumping! (dp)
- UML之状态图
- effective C++(二)
- Remove Duplicates from Sorted Array
- 处理大并发之 libevent demo详细分析(对比epoll)
- Linux-->基础知识-->Linux下chkconfig命令详解
- 为什么InetAddress类不能new初始化但可以定义对象:The constructor InetAddress() is not visible
- 修改Linux字符集
- 小鼠迷宫类问题
- Android Studio常用操作技巧(不断更新)
- 《Programming in Lua 3》读书笔记(九)
- 处理大并发之 对libevent的初步认识