数组 Remove Duplicates from Sorted Array
来源:互联网 发布:手机怎样在淘宝买东西 编辑:程序博客网 时间:2024/06/11 21:54
<span style="font-size:18px;">class Solution {public: int removeDuplicates(int A[], int n) { if(n == 0) return 0; int index = 0; for(int i = 1; i < n ; i++) { if(A[index] != A[i]) { A[++index] = A[i]; } } return index+1; }};</span>
思想:
给定数组已排序,用index变量来控制,重复的跳过,不重复的写入覆盖。
0 0
- 数组之Remove Duplicates from Sorted Array
- 数组 Remove Duplicates from Sorted Array
- 数组 Remove Duplicates from Sorted Array II
- leetcode:数组: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
- 43. PHP 流程控制的替代语法
- GMP和PBC环境搭建
- Git学习和开源精神
- Java基础第十九天--GUI
- 二叉树--顺序结构
- 数组 Remove Duplicates from Sorted Array
- soapui+groovy进行接口自动化测试浅谈
- 蓝桥杯:第三十九级台阶
- Spring BlazeDS Integration Reference Guide
- LeetCode Sort Colors
- 44. PHP while
- 张伟平得罪巩俐:在张艺谋面前捏造其劈腿
- 蝶恋花
- 欢迎使用CSDN-markdown编辑器