The block of mass M moving on the frictionless horizontal surface collides with the spring of spring constant K and compresses it by length L. The maximum momentum of the block after collision is
When block of mass M collides with the spring its kinetic energy gets converted into elastic potential energy of the spring.
From the law of conservation of energy
Where v is the velocity of block by which it collides with spring. So, its maximum momentum
After collision the block will rebound with same linear momentum.