码迷,mamicode.com
首页 > 其他好文 > 详细

27. Remove Element

时间:2016-04-05 00:28:16      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

public class Solution {
    public int removeElement(int[] nums, int val) {
        int sum=0;
        int len=nums.length;
        int end=len;
        int i=0;
        while(i<end)
        {
            if(nums[i]==val)
            {
                sum++;
                for(int j=i+1;j<end;j++)
                {
                    nums[j-1]=nums[j];
                }
                end--;
                continue;
            }
            i++;
        }
        return len-sum;
    }
}

 

27. Remove Element

标签:

原文地址:http://www.cnblogs.com/aguai1992/p/5353157.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!