Available question text
Count how many non-adjacent battleships (each a straight 1×k or k×1 segment) appear in an m×n grid of 'X' and '.' cells. Because ships never touch, you can scan the board once and identify each ship by its starting cell (no 'X' above or to the left), achieving one-pass O(1) extra space.
Related questions
Continue with questions that share topics or the same question type.
- Alphabet Board Path
Coding · Hash Table · String
- Count Distinct Numbers on Board
Coding
- Design and implement a Connect-N game on an infinite board
Coding
- Minimum Moves to Get a Peaceful Board
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 419. Battleships in a Board
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source