Problem · Array
First Completed Mingo Line
Learn this problemProblem statement
You are given an n x n board of distinct integers and a sequence called.
Process calls from left to right. A Mingo is completed when every value in a row, a column, or the main top-left-to-bottom-right diagonal has been called.
Return [1, k] when the first Mingo appears after exactly k calls. If the full sequence produces no Mingo, return [0, called.length]. Repeated values and values absent from the board still count as calls but do not mark another cell.
Function
firstMingo(board: int[][], called: int[]) → int[]Examples
Example 1
board = [[1,2,3],[4,5,6],[7,8,9]]called = [1,5,2,9]return = [1,4]Calls 1, 5, and 9 complete the main diagonal on the fourth call.
Example 2
board = [[1,2],[3,4]]called = [4]return = [0,1]One marked cell does not complete a row, column, or the main diagonal.
Constraints
1 <= n <= 500boardcontains distinct integers from1through1000000.1 <= called.length <= 1000000