NeetCode #173LC-1274HardArrays & Hashing
← Back to All Problems

#173 · #1274 · Number of Ships in a Rectangle(矩形内船只的数目)

📌 Problem Statement & Constraints

This is an interactive problem. A Sea object has a hasShips(topRight, bottomLeft) method returning whether any ship exists in the given axis-aligned rectangle (inclusive). Given the rectangle bounds, return the total number of ships. Constraints: 0 <= ships <= 10, coordinates are up to 1000 x 1000, and hasShips may be called at most 400 times.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!