Solution:

Let AD be the flagstaff and CD be the building.
Assume that the flagstaff and building subtend equal angles at point B.
Given that AD = 50 m, CD = h and BC = 200 m
Let ∠ABD = $$\theta $$, ∠DBC = $$\theta $$ (∵ flagstaff and building subtend equal angles at a point on level ground).
Then, ∠ABC = 2$$\theta $$
$$\eqalign{
& {\text{From}}\,{\text{the}}\,{\text{right}}\,\Delta BCD, \cr
& \tan \theta = \frac{{DC}}{{BC}} \cr
& \,\,\,\,\,\,\,\,\,\,\,\,\,\,\, = \frac{h}{{200}}\,......\left( 1 \right) \cr
& {\text{From}}\,{\text{the}}\,{\text{right}}\,\Delta BCA, \cr
& \tan 2\theta = \frac{{AC}}{{BC}} \cr
& \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, = \frac{{AD + DC}}{{200}} \cr
& \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, = \frac{{50 + h}}{{200}} \cr} $$
$$ \Rightarrow \frac{{2\tan \theta }}{{1 - {{\tan }^2}\theta }} = \frac{{50 + h}}{{200}}$$ $$\left( {\because \tan \left( {2\theta } \right) = \frac{{2\tan \theta }}{{1 - {{\tan }^2}\theta }}} \right)$$
$$\frac{{2\left( {\frac{h}{{200}}} \right)}}{{1 - \frac{{{h^2}}}{{{{200}^2}}}}} = \frac{{50 + h}}{{200}}$$ (∵ substituted value of tan $$\theta $$ from eq:1)
$$\eqalign{
& \Rightarrow 2h = \left( {1 - \frac{{{h^2}}}{{{{200}^2}}}} \right)\,\left( {50 + h} \right) \cr
& \Rightarrow 2h = 50 + h - \frac{{50{h^2}}}{{{{200}^2}}} - \frac{{{h^3}}}{{{{200}^2}}} \cr} $$
$$ \Rightarrow 2\left( {{{200}^2}} \right)h = 50{\left( {200} \right)^2} + $$ $$h{\left( {200} \right)^2} - $$ $$50{h^2} - {h^3}$$
(∵ multiplied LHS and RHS by $${{{200}^2}}$$ )
h
3 + 50h
2 + (200)
2h - (200)
250 = 0