LEETCODE remove-element Solution

| August 01, 2015

The correct, optimal and working solution for programming question remove-element on leetcode

class Solution {
public:
    int removeElement(int A[], int n, int elem) {
        int index = 0;
        for( int i = 0 ; i < n ; i++ ) {
            if( A[i] == elem ) {
                
            }
            else {
                A[index++] = A[i];
            }
        }
        return index;
    }
};