/**
 * Problem: #27 Remove Element
 *
 * Idea: One point to count numbers of elements to delete, the other is for the current
 * position to store the values that are not going to be deleted.
 *
 * Solutions:
 *  removeElement: two pointers
 */
public class RemoveElement {
    public int removeElement(int[] nums, int val) {
        int counter = 0;
        int current = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == val) {
                counter ++;
            } else {
                nums[current] = nums[i];
                current ++;
            }
        }
        return nums.length - counter;
    }
}

@@ -323,33 +323,8 @@
 ) %7B%0A
-        int counter = 0;%0A
     
@@ -344,16 +344,16 @@
 nt = 0;%0A
+
         
@@ -416,17 +416,17 @@
 nums%5Bi%5D 
-=
+!
 = val) %7B
@@ -430,57 +430,8 @@
 ) %7B%0A
-                counter ++;%0A            %7D else %7B%0A
     
@@ -538,29 +538,15 @@
 urn 
-nums.length - counter
+current
 ;%0A  

remove unused counter