1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     int removeElement(vector<int>& nums, int val) 
12     {
13         int i=0,j=0;
14         while(j<nums.size())
15         {
16             if(nums[j]!=val)
17                 nums[i++]=nums[j];
18             j++;
19         }
20         return i;
21     }
22 };

还是双指针,前一个存储,后一个比较。

posted on 2018-04-16 11:20  高数考了59  阅读(101)  评论(0)    收藏  举报