Implemented the solution to remove elements of an array in place and return the new length