You are given a positive integer
A 2D integer array row_conditions of size row_conditions[i] = [above[i], below[i]]. This indicates that above[i] must appear in a row above below[i] in the final matrix.
A 2D integer array col_conditions of size col_conditions[i] = [left[i], right[i]]. This indicates that left[i] must appear in a column to the left of right[i] in the final matrix.
Both arrays contain integers ranging from
You need to construct a
For each pair row_conditions[i], the integer above[i] must be located in a row strictly above below[i].
For each pair col_conditions[i], the integer left[i] must be positioned in a column strictly to the left of right[i].
If it’s possible to create such a matrix, return any valid matrix. If it’s not possible, return an empty matrix.
Constraints:
You are given a positive integer
A 2D integer array row_conditions of size row_conditions[i] = [above[i], below[i]]. This indicates that above[i] must appear in a row above below[i] in the final matrix.
A 2D integer array col_conditions of size col_conditions[i] = [left[i], right[i]]. This indicates that left[i] must appear in a column to the left of right[i] in the final matrix.
Both arrays contain integers ranging from
You need to construct a
For each pair row_conditions[i], the integer above[i] must be located in a row strictly above below[i].
For each pair col_conditions[i], the integer left[i] must be positioned in a column strictly to the left of right[i].
If it’s possible to create such a matrix, return any valid matrix. If it’s not possible, return an empty matrix.
Constraints: