Qualcomm interview question

Leetcode Hard problem for rectangles