Remove Duplicates from Sorted Array
来源:互联网 发布:3g模型 淘宝 编辑:程序博客网 时间:2024/04/30 14:42
本题逻辑也算清晰,维护一个n和有效数组的index就行,且递减的n和递增的index是互补的关系:
int removeDuplicates(int A[], int n) { int result = n, count = 0, index = 0; for (int i = 0; i < n - 1; i++) { if (A[i] != A[i + 1]) { index++; A[index] = A[i + 1]; } else { result--; } } return result;}
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
- 看图学英语单词之engage
- Matlab 将.mat文件转化为.txt文件保存
- 1 第一个测试工程HelloWord
- 使用二分法求整数幂
- 解决Python不能发邮件问题
- Remove Duplicates from Sorted Array
- android 之 Handler 详解----(二)常见的使用的基本方式
- eclipse下的tomcat启动抛出了内存溢出的错误。
- Date_Time(继承)
- python中消除冗余参数的方法
- curl上传文件到远程,php版本不同的做法
- android draw9patch工具使用
- NGUI学习笔记 - 通过UIEventlistener和UIbutton来学习NGUI的消息机制
- may 6 s