Answer
$20\;\rm cm$
Work Step by Step
In the first case, we are given that
$$s_1=\bf 10\;\rm cm$$
and
$$m_1=\dfrac{h'}{h}=\bf 2$$
And since we have an upright image and then an inverted image for the same lens, it must be a converging lens.
We also know that
$$m=-\dfrac{s'}{s}=2$$
Thus,
$$s'_1=-2s_1=-2(10)=\bf -20\;\rm cm$$
Now we can find the focal length,
$$f=\left[ \dfrac{1}{s_1}+\dfrac{1}{s'_1}\right]^{-1}$$
Plugging the known;
$$f =\left[ \dfrac{1}{10}+\dfrac{1}{-20}\right]^{-1}$$
$$f ={\bf 20}\;\rm cm$$
In the second case, the object remains constant while the lens itself is moving where we know that
$$m_2=-2$$
So,
$$ m_2=-\dfrac{s'_2}{s_2}$$
Hence,
$$s'_2=-m_2 s_2$$
Using the lens formula,
$$\dfrac{1}{f }= \dfrac{1}{s_2}+\dfrac{1}{-m_2 s_2} $$
$$\dfrac{1}{f }= \dfrac{-m_2s_2+s_2}{-s_2(m_2 s_2)} =\dfrac{m_2-1}{m_2 s_2}$$
Solving for $s_2$
$$ s_2 =\left[\dfrac{m_2-1}{m_2}\right]f$$
Plugging the known;
$$ s_2 =\left[\dfrac{-2-1}{-2}\right](20)=\bf 30\;\rm cm $$
Now we need to find the distance traveled by the lens which is given by
$$x=s_2-s_1=30-10$$
$$x=\color{red}{\bf 20}\;\rm cm$$