Back to problems

Validate N×N Grid as Latin Square

Algorithm · Walmart Labs · Medium

Requirements The input is grid: int[][], containing n rows and m columns. Produce true exactly if n equals m, all entries fall within [1, n], and each row and column includes every number once and only once. Produce false when the grid is not square, when a required number is absent, when a row or column repeats a number, or when an entry lies outside the permitted range. Examples Every row and every column contains 1, 2, and 3 exactly one time. The value 4 is not allowed…

Checking your access…