赞
踩
题目:
题解:
- class Solution {
- public:
- int removeDuplicates(vector<int>& nums) {
- int n = nums.size();
- if (n == 0) {
- return 0;
- }
- int fast = 1, slow = 1;
- while (fast < n) {
- if (nums[fast] != nums[fast - 1]) {
- nums[slow] = nums[fast];
- ++slow;
- }
- ++fast;
- }
- return slow;
- }
- };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。