Practice Problem

Construct Quad Tree

Difficulty: Medium

Given an n x n binary matrix, construct a Quad-Tree representation by recursively partitioning the grid into four equal quadrants.