Impulse = (force) x (time)
The first impulse was (20 N) x (10 sec) = 200 meters/sec
The second one is (50 N) x (time) and we want it equal to the first one, so
(50 N) x (time) = 200 meters/sec
Divide each side by 50N : Time = 200/50 = 4 seconds
By the way, the quantity we're playing with here is the cart's momentum.