queens[i] = [x, y] is the cell of the i-th queen and king = [x, y] is the king's cell.
A queen attacks the king if they share a row, a column or a diagonal and no other piece stands between them.
Return the coordinates of every queen that attacks the king, in any order.queens=[[2, 2], [5, 5], [2, 6], [6, 2], [4, 7]], king=[4, 4] → [[2, 2], [2, 6], [4, 7], [6, 2], [5, 5]]
The queens [2, 2], [5, 5], [2, 6] and [6, 2] see the king along diagonals. The queen [4, 7] shares the king's row with nothing in between, so it attacks too.
queens=[[0, 1], [0, 3], [3, 0]], king=[0, 0] → [[0, 1], [3, 0]]
The queen [0, 3] is blocked by [0, 1], while [3, 0] attacks along the column.
queens=[[1, 2], [2, 1]], king=[0, 0] → []
Both queens are a knight's move away from the king, so no line connects them.
queens=[[2, 2], [5, 5], [2, 6], [6, 2], [4, 7]], king=[4, 4]
[[2, 2], [2, 6], [4, 7], [6, 2], [5, 5]]
Run checks the first 3 tests in your browser. Submit checks all 63 tests on the server, hidden ones included.