Programming problem: Remove Element
Use a write pointer to overwrite matching values in place: iterate the array, and for each element not equal to `val`, write it at the pointer position and advance. Returns `k` non-matching elements in O(n) time and O(1) space.