Back to problems

Find a Length-3 Battleship in an N×N Grid Using a Hit/Miss API

Low-Level Design · Meta · Medium

Problem: Locate a Length-3 Battleship in an N×N Grid Through a Hit/Miss API You have an N × N square board, where N >= 3. Each board location uses coordinates (x, y), with 0 bomb_location(x, y) -> bool Produces True when (x, y) belongs to the battleship (a hit). Produces False when that coordinate is not occupied (a miss). Task Create: find_battleship(N) -> ((x1,y1), (x2,y2), (x3,y3)) It must return all three coordinates containing the battleship. Their ordering is…

Checking your access…