乐趣区

关于leetcode:27-Remove-Element

class Solution {public int removeElement(int[] nums, int val) {
        int i;
        for(i = 0; i < nums.length ; i++) {if(nums[i]==val) {
                int j;
                for(j = nums.length - 1; j > i; j--) {if(nums[j]!=val) {break;}
                }
                if(j == i)
                    break;
                nums[i]=nums[j];
                nums[j]=val;
            }
        }
        return i;
    }
}
退出移动版