...

/

Build a Matrix with Conditions

Build a Matrix with Conditions

Try to solve the Build a Matrix with Conditions problem.

Statement

You are given a positive integer kk, and you’re also given two conditions:

  • A 2D integer array rowConditions of size nn, where rowConditions[i] = [above[i], below[i]]. This means that above[i] must appear in a row above below[i] in the final matrix.

  • A 2D integer array colConditions of size mm, where colConditions[i] = [left[i], right[i]]. This means that left[i] must appear in a column to the left of right[i] in the final matrix.

Both arrays contain integers from 11 to kk.

Your task is to build a k ...