The wording of the problem implies that there is no friction.
The potential energy of the block--at the top of the ramp--is converted to kinetic energy on the flat segment
This kinetic energy is then converted to potential energy in the spring.
The potential energy in the spring is converted back to kinetic energy, which is then converted back to potential energy as the block goes back up the ramp.
With no friction, and no losses in the spring, the block returns to the same height where it started