Remove Element — a write pointer keeps the survivors
Scan every value. Each one that isn't the target gets copied to the write pointer, which then advances. The write pointer ends at the count of kept elements.
Try:
kept count (return value): 0