As reported: ServiceNow Software Engineer (IC2) loop, round 4 (DSA + database design), May 2025: a modified Maximal Square that also asks for the square's coordinates, and a database design question.
Given an m × n matrix of 0s and 1s, find the largest square containing only 1s. Return [side, row, col], where (row, col) is the square's top-left cell (0-indexed). If several squares have the largest side, return the one whose top-left cell comes first in row-major order (smallest row, then smallest col). If the matrix has no 1, return [0, -1, -1].
This builds on LeetCode 221 — Maximal Square, which returns only the area.
Example
[[1,0,1,0,0],
[1,0,1,1,1],
[1,1,1,1,1],
[1,0,0,1,0]] -> [2,1,2] (rows 1–2, columns 2–3)
[[0,1],[1,0]] -> [1,0,1]
[[0]] -> [0,-1,-1]
Constraints: 1 ≤ m, n ≤ 300; cells are 0 or 1.
Code runner format: one line with the matrix as a JSON array of integer rows. Implement largestSquare(matrix); the harness prints [side, row, col].