Back to QuestionsPractice with This Question
Battleships in a Board
122.3K views•Asked at Uber•
Medium
Question Explain
Given an $m \times n$ board where 'X's represent battleships and '.'s represent water, count the number of battleships. Battleships are placed horizontally or vertically, and are separated by water. Solve in $O(n)$ without modifying the board.
Start Trying This Question Simulation
Practice answering orally or with text to get instant AI feedback.