package leetcode;

/**
 * Author:Young
 * Class Comment:Remove Element
 * Date: 2016年5月4日下午10:13:57
 */
public class NO_027 {
	public static void main(String[] args) {
		int[] nums = {3,3};
		System.out.println(new NO_027().removeElement(nums, 3));
	}
	public int removeElement(int[] nums, int val) {
		if(nums == null || nums.length == 0)
			return 0;
		int start = 0, end = nums.length-1;
		while(start < end){
			if(nums[start] == val){
				while(start < end && nums[end] == val)
					end--;
				if(start < end && nums[end] != val){
					nums[start] = nums[end];
					start++;
					end--;
				} else{
					start--;
					break;
				}
			} else{
				start++;
			}
		}
		if(start == -1)
			return 0;
		if(start > end)
			return start;
		if(nums[start] == val)
			start--;
		start++;
        return start;
    }
}

@@ -257,16 +257,39 @@
 );%0D%0A%09%7D%0D%0A
+%09%0D%0A%09//simple solution%0D%0A
 %09public 
@@ -330,16 +330,245 @@
 val) %7B%0D%0A
+%09%09int i = 0, j = nums.length-1;%0D%0A%09%09while(i%3C=j)%7B%0D%0A%09%09%09if(nums%5Bi%5D == val)%7B%0D%0A%09%09%09%09nums%5Bi%5D = nums%5Bj%5D;%0D%0A%09%09%09%09j--;%0D%0A%09%09%09%09continue;%0D%0A%09%09%09%7D%0D%0A%09%09%09i++;%0D%0A%09%09%7D%0D%0A%09%09return i;%0D%0A%09%7D%0D%0A%09//my solution %0D%0A%09public int removeElement_me(int%5B%5D nums, int val) %7B%0D%0A
 %09%09if(num

remove element in simple solution