leetcode: Remove Duplicates from Sorted Array
来源:互联网 发布:3g网络网速 编辑:程序博客网 时间:2024/05/20 16:10
扫描数组,用一个指针维护去重后的的数组。 这样在不需要额外数组空间的情况下可以获得去重数组的长度并且排列在A的前端。
public class Solution { public int removeDuplicates(int[] A) { if(A==null||A.length==0) { return 0; } int len = A.length; int res=1; for( int i=1;i<len;i++ ) { if(A[i]==A[res-1]) { continue; } A[res]=A[i]; res++; } return res; }}
0 0
- [leetcode][array] Remove Duplicates from Sorted Array
- 【Leetcode】【Array】Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array
- [Leetcode] Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- leetcode 35: Remove Duplicates from Sorted Array
- [LeetCode] Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array
- Leetcode: Remove Duplicates from Sorted Array
- [leetcode] Remove Duplicates from Sorted Array II
- [LeetCode]Remove Duplicates from Sorted Array
- [LeetCode]Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted Array
- [leetcode]Remove Duplicates from Sorted Array II
- Redis源码学习1——基本数据结构sds
- ubuntu14.04安装eclipse
- 支付宝开发经验
- 50个常用sql语句
- spring配置文件中的mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations区别
- leetcode: Remove Duplicates from Sorted Array
- Redis源码学习2-内存管理
- xsd转化为XML格式
- WebAPI 添加模型验证
- 避免Block中的强引用环
- Struts 1.x | <logic> 标签库
- Java中单例类和不可变类的理解
- Single Number
- php中抽象类abstruct和接口interface的共同点与不同点区别