@@ -0,0 +1,1096 @@
+package easy;%0D%0A%0D%0Aimport utils.CommonUtils;%0D%0A%0D%0A/**27. Remove Element%0D%0A%0D%0A    Total Accepted: 135216%0D%0A    Total Submissions: 384018%0D%0A    Difficulty: Easy%0D%0A%0D%0AGiven an array and a value, remove all instances of that value in place and return the new length.%0D%0A%0D%0ADo not allocate extra space for another array, you must do this in place with constant memory.%0D%0A%0D%0AThe order of elements can be changed. It doesn't matter what you leave beyond the new length.%0D%0A%0D%0AExample:%0D%0AGiven input array nums = %5B3,2,2,3%5D, val = 3%0D%0A%0D%0AYour function should return length = 2, with the first two elements of nums being 2.*/%0D%0Apublic class RemoveElement %7B%0D%0A%09public int removeElement(int%5B%5D nums, int val) %7B%0D%0A%09%09for(int i = 0; i %3C nums.length; i++)%7B%0D%0A%09%09%09int start = i;%0D%0A%09%09%09while(i %3C nums.length && nums%5Bi%5D == val)%7B%0D%0A%09%09%09%09i++;%0D%0A%09%09%09%7D%0D%0A%09%09%09if(i == nums.length) i--;%0D%0A%09%09%09nums%5Bstart%5D = nums%5Bi%5D;%0D%0A%09%09%7D%0D%0A%09%09CommonUtils.printArray(nums);%0D%0A%09%09return 0;%0D%0A%09%7D%0D%0A%09%0D%0A%09public static void main(String...strings)%7B%0D%0A%09%09RemoveElement test = new RemoveElement();%0D%0A%09%09int%5B%5D nums = new int%5B%5D%7B3,2,2,3%7D;%0D%0A%09%09int val = 3;%0D%0A%09%09test.removeElement(nums, val);%0D%0A%09%7D%0D%0A%7D%0D%0A

remove element in progress