Remove Element
void swap(int* a,int* b) { int tmp = *a; *a = *b; *b = tmp; } class Solution { public: int removeElement(int A[], int n, int elem) { // Note: The Solution object is instantiated only once and is reused by each test case. int i = 0; int j = n; while(i<j) { if(A[i]==elem) { j--; swap(&A[i],&A[j]); }else i++; } return j; } };