feat(content): function signatures + test cases
This commit is contained in:
@@ -9,6 +9,26 @@ categories:
|
||||
patterns:
|
||||
- matrix-traversal
|
||||
|
||||
function_signature: "def count_battleships(board: list[list[str]]) -> int:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { board: [["X", ".", ".", "X"], [".", ".", ".", "X"], [".", ".", ".", "X"]] }
|
||||
expected: 2
|
||||
- input: { board: [["."]] }
|
||||
expected: 0
|
||||
hidden:
|
||||
- input: { board: [["X"]] }
|
||||
expected: 1
|
||||
- input: { board: [["X", "X", "X"]] }
|
||||
expected: 1
|
||||
- input: { board: [["X"], ["X"], ["X"]] }
|
||||
expected: 1
|
||||
- input: { board: [["X", ".", "X"], [".", ".", "."], ["X", ".", "X"]] }
|
||||
expected: 4
|
||||
- input: { board: [[".", ".", "."], [".", ".", "."], [".", ".", "."]] }
|
||||
expected: 0
|
||||
|
||||
description: |
|
||||
Given an `m x n` matrix `board` where each cell is a battleship `'X'` or empty `'.'`, return *the number of **battleships** on the board*.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user