feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent 9e6c6d256f
commit 65a8d525f5
203 changed files with 4526 additions and 0 deletions

View File

@@ -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*.