标签:out span http remove for cto amp eps size
1 #include <iostream>
2 #include <vector>
3
4 using namespace std;
5
6 class Solution {
7 public:
8 int removeDuplicates(vector<int>& nums)
9 {
10 int val = nums.size();
11 int i = 0;
12 for (int j = 1; j < val; j++)
13 {
14 if (nums[i] == nums[j])
15 {
16 continue;
17 }
18 else
19 {
20 nums[i+1] = nums[j];
21 i += 1;
22 }
23 }
24 return i+1;
25 }
26 };
27
28 int main()
29 {
30 vector<int> nums = { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 };
31 int length;
32 Solution sol;
33 length = sol.removeDuplicates(nums);
34 cout << length << endl;;
35 int n;
36 for (int i = 0; i < length; i++)
37 {
38 cout << nums[i] << endl;
39 }
40 cin >> n;
41 return 0;
42 }
力扣(LeetCode)试题26-删除排序数组中的重复项 C++代码
标签:out span http remove for cto amp eps size
原文地址:https://www.cnblogs.com/pgzhanglin/p/13228737.html