Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Can you use backtracking to solve this problem ?.
Suppose you've placed a bunch of squares. Where is the natural spot to place the next square ?.
The maximum number of squares to be placed will be ≤ max(n,m).