36 cm
Let s represent the side of the square in cm. Then s+3 and s-2 are the sides of the rectangle of interest.
The area of the rectangle is the product of its side lengths:
... rectange area = (s+3)(s-2) = s² +s -6
The area of the square is the product of its side lengths, both of which are s.
... square area = s²
The difference of these areas is 30 cm², so ...
... rectangle area - square area = 30
... (s² +s -6) -(s²) = 30
... s = 36 . . . . . . . . . . . . simplify, add 6
The side of the square is 36 cm.
_____
Check
The rectangle dimensions are 39 cm by 34 cm, so its area is
... (39 × 34) cm² = 1326 cm²
The area of the square is (36 cm)² = 1296 cm²
The difference in areas is (1326 -1296) cm² = 30 cm², as required.