Complete a small grid so that the four marked cells form the corners of an axis-aligned square.
You are given a square grid containing exactly four marked cells represented by # and all other cells represented by ..
Your task is to add the minimum number of # cells so that the four original marked cells become the corners of an axis-aligned square. The square may be larger than the current arrangement, but its sides must be parallel to the grid axes.
If the four existing marked cells already form a square, the grid should remain unchanged.
Return the final grid after placing the extra marks.
# cells are guaranteed to be positioned so that a valid square can be completed.t, the number of test cases.. or # describing the grid.For each test case, output the completed 4 x 4 grid after adding the missing # cells.
1 <= t <= 1004 x 4#Example 1
Input
1 .... .#.. .... ..#.
Output
.... .#.# .... .#.#
Explanation
The marked cells are on different rows and columns. Completing the square requires adding the other two corners at the matching row/column intersections.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.