here's a short soln. i hope this helps
equation for small block
(

/2)mg = ma
s (a
s = acceleration of small block w.r.t ground)
=> a
s = (

/2)g (towards left)
similarly equation for larger block

(M+m)g - (

/2)mg = Ma
L (where a
L = acceleration of larger block w.r.t ground )
=> a
L = [(

/2)(m/M)]g +

g (towards left)
now a
sL = a
s - aL = (

/2)g - ( [(

/2)(m/M)]g +

g ) (a
sL = acceleration of small block w.r.t bigger block)
=> a
sL = [{

g(M+m)}/2M] (towards right)
now
l = 1/2 * asL * t^2
l = 1/2 * [{

g(M+m)}/2M] * t^2
t^2 = 4Ml/[

g(M+m)]
t = sqroot(4Ml/[

g(M+m)])
hope you understod
cheers