Search
⌘K

Leetcode 1274. Number of Ships in a Rectangle

Given a black-box API hasShips(topRight, bottomLeft) that returns whether at least one ship (point at integer coordinates) lies inside an axis-aligned rectangle, compute the exact number of ships in a target rectangle by recursively subdividing the region (quadtree/divide-and-conquer), pruning empty subrectangles and stopping when a region reduces to a single point.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.