Back to Questions

Battleships in a Board

122.3K viewsAsked 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.

Practice with This Question