The initial kinetic energy of the cart is

(1)
where m is the mass of the cart and v its initial velocity.
Then, the cart hits the spring compressing it. The maximum compression occurs when the cart stops, and at that point the kinetic energy of the cart is zero, so all its initial kinetic energy has been converted into elastic potential energy of the spring:

where k is the spring constant and x is the spring compression.
For energy conservation, K=U. We can calculate U first: the compression of the spring is x=60 cm=0.60 m, while the spring constant is k=250 N/m, so

So, the initial kinetic energy of the cart is also 45 J, and from (1) we can find the value of the initial velocity: