#3143

Maximum Points Inside the Square

medium · 39.2% accepted · 170 likes · top 18%

array · hash table · string · binary search · sorting

⊣ practice⊣ open on leetcode ↗

Description

You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i.

A valid square is a square centered at the origin (0, 0), has edges parallel to the axes, and does not contain two points with the same tag.

Return the maximum number of points contained in a valid square.

Note:

- A point is considered to be inside the square if it lies on or within the square's boundaries.

- The side length of the square can be zero.

Solution