Remove Duplicates from Sorted Array II
来源:互联网 发布:杭州树熊网络怎么样 编辑:程序博客网 时间:2024/05/17 22:45
还是原地重写法。保留的条件是A[j]!=A[i-2],注意后面的下标是i-2,不是j-2
int removeDuplicates(int A[], int n) { if(n<3) return n; int i=2; for(int j=2;j<n;j++) { if(A[j]!=A[i-2]) { A[i] = A[j]; i++; } } return i; }
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
- django schema migration
- C++简洁实现线程安全单例类
- 树莓派config配置详情
- 关于Android编译非device目录下复制文件
- 12.1 Jump Game
- Remove Duplicates from Sorted Array II
- Java Web开发中路径问题小结
- poj 2299 Ultra-QuickSort 归并排序 线段树
- POJ 3691 DNA repair
- indexOf(String.indexOf 方法)
- 过滤方法简要笔记
- linux使用flock文件锁解决crontab冲突问题
- 7.29_java学习_Runtime类
- poj 3414 Pots 广度优先搜索