## Example CodeSignal questions for software engineering interviews

You are given a matrix of integers `field` shaped `height × width` representing a playing field, and also a matrix of integers `figure` shaped `3 × 3` representing a figure. In both matrices only `0`sand `1`s, where `1` means that the cell is occupied, and `0` This means that the sale is free.

You choose a position at the top of the playing field where you put the figure and then drop it down. The figure falls down until it either reaches the ground (below the field) or reaches an occupied cell, which prevents it from falling further. After the figure stops falling, some rows of fields may be completely busy.

Your task is to find the dropping position in such a way that there is at least one complete row. As a dropping condition, you should return the column index of the cell in the playing field that corresponds to the upper left corner of the figure. `3 × 3` matrix. If there are multiple dropping positions that satisfy the condition, feel free to return any of them. If there is no such dropping position, return `-1`,

Note: The figure should be dropped so that its entire `3 × 3` The matrix fits inside the region, even if part of the matrix is ​​empty.

Example

For
`field = [[0, 0, 0],         [0, 0, 0],         [0, 0, 0],         [1, 0, 0],         [1, 1, 0]]`
And
`figure = [[0, 0, 1],         [0, 1, 1],         [0, 0, 1]]`

output should be `solution(field, figure) = 0`,

Because the area is a 3 x 3 matrix, the figure can only be dropped from the position `0`, When the figure stops falling, two perfectly spaced rows are formed, hence the falling position `0` satisfies the condition.

For
`field =  [[0, 0, 0, 0, 0],          [0, 0, 0, 0, 0],          [0, 0, 0, 0, 0],          [1, 1, 0, 1, 0],          [1, 0, 1, 0, 1]]`

And
`figure = [[1, 1, 1],          [1, 0, 1],          [1, 0, 1]]`

output s. should be`olution(field, figure) = 2`,

The figure can be dropped from three positions: `0`, `1`And `2`, As you can see below, a fully occupied row will be formed only when the position falls from `2`,

For
`field =  [[0, 0, 0, 0],          [0, 0, 0, 0],          [0, 0, 0, 0],          [1, 0, 0, 1],          [1, 1, 0, 1]]`

And
`figure = [[1, 1, 0],          [1, 0, 0],          [1, 0, 0]]`

output should be `solution(field, figure) = -1`,

The figure can be dropped from two positions, `0` And `1`And in both cases, the fully occupied row will not be obtained:

Note that the figure could technically form a complete row if it were dropped one position further to the right, but this is not a valid dropping position, as the 3 x 3 figure matrix would not be completely contained in the area.