Practice Maximize the Distance Between Points on a Square
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer side, representing the edge length of a square with corners at (0, 0), (0, side), (side, 0), and (side, side) on a Cartesian plane. You are also given a positive integer k and a 2D integer array points, where points[i] = [xi, yi] represents the coordinate of a point lying on the boundary of the square. You need to select k elements among points such that the minimum Manhattan distance between any two points is maximized. Return the maximum possible minimum Manhattan distance between the selected k points. The Manhattan Distance between two cells (xi, yi) and (xj, yj) is |xi - xj| + |yi - yj|.
Source: Maximize the Distance Between Points on a Square on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
side = 2, points = [[0,2],[2,0],[2,2],[0,0]], k = 4
2
# Example 2
side = 2, points = [[0,0],[1,2],[2,0],[2,2],[2,1]], k = 4
1
# Example 3
side = 2, points = [[0,0],[0,1],[0,2],[1,2],[2,0],[2,2],[2,1]], k = 5
1
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize the Distance Between Points on a Square.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.