Let the maximum elongation in the spring be x, when the block is at position 2.
a. The displacement of the block `m` is also `x`.
From conservation of energy, `DeltaK=DeltaU=0`
`=1/2kx^2=mgx`
`impliesx=2mg//k`
b. Let maximum velocity occur when block moves a distance `x`.
Using `DeltaK+DeltaU=0`
`(1/2mv^2-0)+(-mgx+1/2kx^2)=0`
or `1/2mv^2=mgx-1/2kx^2`
Differeciating above equations w.r.t. x
`1/2m*2v*(dv)/(dx)=mg(dx)/(dt)-1/2k2x(dx)/(dt)`
`mv*(dv)/(dt)=mgv-kxv`
For maximum v, `(dv)/(dx)=0impliesx=(mg)/(k)`
So, `mg((mg)/(k))-1/2k((mg)/(k))^2=1/2mv_(max)^2`
`impliesv_(max)=(sqrt(m/k))g`