First Completed Mingo Line
Updated
Problem 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
More Epic Online Assessment questions
Similar questions at other companies
- Game of Life on a Finite and an Infinite BoardCitadel · PHONE SCREENCitadel interview questions
- Cache Shared Image Pipeline PrefixesAnthropic · ONSITE INTERVIEWAnthropic interview questions
- Payment Partner RoutingStripe · OAStripe interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
- Process Banking OperationsVercel · OA
- Maximum Diamond SumHudson River Trading · OAHudson River Trading interview questions
- Robot Navigation Around LasersRoblox · OARoblox interview questions
- Apply a Reversi MoveAmazon · OA
- Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions