26. Remove Duplicates from Sorted Array
2016-07-01 00:00
393 查看
public class RemoveDuplicates { public int removeDuplicates(int[] nums) { int nlength = 0; int tmp = 0; for(int i = 0; i< nums.length; i++){ if(i >= 1){ if(tmp < nums[i]){ nlength++; tmp = nums[i]; } } else { tmp = nums[i]; nlength++; } } return nlength; } public static void main(String[] args) { RemoveDuplicates rd = new RemoveDuplicates(); System.out.println(rd.removeDuplicates(new int[]{1,1,1})); } }
相关文章推荐
- 27. Remove Element
- 28. Implement strStr()
- 29. Divide Two Integers
- 30. Substring with Concatenation of All Words
- swiper的基础教程(十二)
- JAVA学习笔记(3-2-函数与重载)
- phpStorm打开提示 failed to create JVM 的解决办法
- 单例模式的反序列化总结
- FTP工作模式分析
- Django数据库读取出下拉框的数据源
- 浅谈开源大数据平台的演变
- 大数据环境下互联网行业数据仓库/数据平台的架构之漫谈
- MySQL数据库PDO教程
- activiti的注意点
- Activiti5工作流实战-5
- Activiti工作流实战-3
- Activiti5工作流实战-4
- 从UIViewController跳转到UITabBarController
- SVN简介
- Java随笔--分布式