Two identical blocks resting on a frictionless, horizontal surface are connected by a light spring having a spring constant $k = 100 N/m$ and an unstretched length $L_i=0.400 m$. A charge $Q$ is slowly placed on each block, causing the spring to stretch to an equilibrium length $L=0.500 m$. Determine the value of $Q$, modeling the blocks as charged particles.
So I was able to solve the problem using particle in equilibrium as follows $$ F_e = k\Delta x \Rightarrow $$ $$ F_e = \frac{k_e Q^2}{L^2} = k(L-L_i) \Leftrightarrow $$ $$ Q= L \sqrt{\frac{k(L-L_i)}{k_e}} = \boxed{ 1.67 \times 10^{-5}C} $$
However, I am trying to solve the problem using conservation of energy, but I am getting a different answer probably due to something wrong I did:
Since the blocks are charged slowly, I ignored kinetic energy: External work done by the force $F_e$ is equivalent to the spring elastic potential energy,
$$ \int_{L_i}^{L} F_e dx = \frac{1}{2}k \left(L-L_i\right)^2 \Rightarrow $$ $$ \int_{L_i}^{L} \frac{k_e Q^2}{x^2} dx = 0.5 \Leftrightarrow $$ $$ \left.\frac{-k_e Q^2}{x}\right|^{0.5}_{0.4} = 0.5 \Leftrightarrow \boxed{Q= 1.05 \times 10^{-5}C } $$ The answers do not match! I assume there is missing energy.