Skip to content

Practice Maximum Points Inside the Square

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3143
LeetCode Problem

Maximum Points Inside the Square

Problem Statement

Given point coordinates points and corresponding tags s, consider squares centered at (0, 0) with sides parallel to the coordinate axes. A point counts as contained when it is on or inside the boundary. A square is valid when it contains no two points with the same tag, and its side length may be zero. Return the maximum number of points contained in a valid square.

Source: Maximum Points Inside the Square on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
points = [[2,2],[-1,-2],[-4,4],[-3,1],[3,-3]], s = "abdca"
Output
2

# Example 2

Input
points = [[1,1],[-2,-2],[-2,2]], s = "abb"
Output
1

# Example 3

Input
points = [[1,1],[-1,-1],[2,-2]], s = "ccd"
Output
0

Constraints

1 <= s.length, points.length <= 10^5
points[i].length == 2
-10^9 <= points[i][0], points[i][1] <= 10^9
s.length == points.length
points consists of distinct coordinates.
s consists only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Maximum Points Inside the Square.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.