A Square Inside A Triangle (but with a twist) I have a right $\triangle ABC$ and I want to find the side length of one of the legs, $x$, when the square is at its max area, as shown in 
I am given that $AB + BC$ is $10$.
Here's what I tried so far:


*

*I found ratios between the sides using similarity, but I wasn't able to get a conclusive answer, just things in terms of each other.

*I tried to set up equations using the Pythagorean theorem, but that just ended up with some messy variable terms and zero actual progress.
The answer is $x=5$, but I want to know how I would go about approaching this kind of problem. It's like others I've seen before here and in other places, but not being given the side lengths threw me off.

The area of the square would be maximal, when $l$ would be maximal.
Let $AB=a$ and $AC=b$.
Thus, $$\frac{a-l}{a}=\frac{l}{b},$$
which by AM-GM gives:
$$l=\frac{ab}{a+b}\leq\frac{\left(\frac{a+b}{2}\right)^2}{a+b}=\frac{5}{2}.$$
The equality occurs for $a=b=5$.
Thus, the area of the square gets a maximal value for $x=5$.
Done!
