网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  Remove Duplicates from Sorted Array @leetcode

Remove Duplicates from Sorted Array @leetcode

分类: IT文章 • 2025-02-06 21:35:07

http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/

 1 class Solution {
 2 public:
 3     int removeDuplicates(int A[], int n) {
 4         int tmp = 0;
 5         for(int i = 1;i < n;++i){
 6             if(A[i] == A[i-1]) ++tmp;
 7             A[i-tmp] = A[i];
 8         }
 9         return n - tmp;
10     }
11 };

!亦是特征向量。直接使用-用后即忘版。

相关推荐

  • LeetCode 26 Remove Duplicates from Sorted Array
  • Remove Duplicates from Sorted Array II
  • Remove Duplicates from Sorted Array @leetcode
  • leetcode-Find Minimum in Rotated Sorted Array II
  • leetcode[108]Convert Sorted Array to Binary Search Tree
  • Leetcode 26. Remove Duplicates from Sorted Array
  • Leetcode 88. Merge Sorted Array
  • 【LeetCode & 剑指offer刷题】链表题4:22 删除链表中倒数第k个结点(19. Remove Nth Node From End of List)
  • Merge Sorted Array [LeetCode]
  • Remove Duplicates from Sorted List II [LeetCode]
  • 笔记整理(转)
  • 重启网卡失败
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号