First find the areas of the two separate rectangles where:
Area of rectangle = length x width
Area of the small rectangle = x(x–4)
Area of small rectangle = 
Area of big rectangle = (x–2)(2x+x)
Area of big rectangle = (x–2)(3x)
Area of big rectangle = 
The total area of the compound shape is 36, therefore:

(collecting like-terms and by bringing the +36 to the other side)
By dividing this by 2, you get:


To find the length of AB (x), solve the quadratic by either factorising, completing the square or by using the quadratic formula, etc to solve for x.




However, a length cannot be negative, so x must be
or 4.5cm, so length AB = 4.5cm.
Hope this helps :)