[刷题]Remove Duplicates from Sorted Array II
来源:互联网 发布:grub4dos引导linux 编辑:程序博客网 时间:2024/05/13 03:18
[LintCode]Remove Duplicates from Sorted Array II
public class Solution { /** * @param A: a array of integers * @return : return an integer */ public int removeDuplicates(int[] nums) { // 2015-4-12 待改进 if (nums == null || nums.length == 0) { return 0; } if (nums.length == 1) { return 1; } int index = 0; boolean secondSame = true; //关键:与第一题的区别 for (int i = 1; i < nums.length; i++) { if (nums[index] != nums[i]) { secondSame = true; index++; nums[index] = nums[i]; } else if (secondSame) { secondSame = false; index++; nums[index] = nums[i]; } } return index + 1; }}
0 0
- [刷题]Remove Duplicates from Sorted Array II
- LeetCode刷题【Array】 Remove Duplicates from Sorted Array II
- 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
- 第五周项目四——静态成员应用
- 构建linux根文件系统
- 第五周项目三 用多文件组织多个类的程序
- Objective-C之run loop详解
- Android 优化布局层次结构
- [刷题]Remove Duplicates from Sorted Array II
- 第九天:poj1011(又是深度搜索+剪枝,还是不会o(∩_∩)o )
- Raspberry Pi + 3个USB摄像头 + Motion(简易监控设备配置记录1——介绍以及安装)
- 网络设备的IP地址结构
- C编译器剖析_5.2.2 中间代码生成及优化_再论符号symbol与公共子表达式
- 泛函编程(20)-泛函库设计-Further Into Parallelism
- Poj 1426 Find The Multiple 【DFS】
- C# Tcp通信服务器的同步和异步方式
- Spring MVC与Struts2的比较