Construct Quad Tree
Construct a quad tree from a square grid of 0s and 1s.
Examples
Input: [[1,1],[1,1]]
Output: [1,true]
Input: [[0,1],[1,0]]
Output: [1,false,[0,true],[1,true],[1,true],[0,true]]
Hints
Represent the grid as a 2D array and define a recursive function that takes the top-left and bottom-right coordinates of the current subgrid to process.
Before splitting, check if the current subgrid is uniform (all 0s or all 1s). If so, return a leaf node with the value and `true` for `isLeaf`.
If the subgrid is not uniform, split it into four equal quadrants (top-left, top-right, bottom-left, bottom-right) and recursively construct the quad tree for each quadrant, then combine them into a non-leaf node with `isLeaf = false`.
Construct Quad Tree
Construct a quad tree from a square grid of 0s and 1s.