Skip to content

Commit d05f6cd

Browse files
committed
Added README.md file for Maximum Points Inside the Square
1 parent bf8e6bd commit d05f6cd

File tree

1 file changed

+65
-0
lines changed
  • 3419-maximum-points-inside-the-square

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-points-inside-the-square">Maximum Points Inside the Square</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>You are given a 2D<strong> </strong>array <code>points</code> and a string <code>s</code> where, <code>points[i]</code> represents the coordinates of point <code>i</code>, and <code>s[i]</code> represents the <strong>tag</strong> of point <code>i</code>.</p>
2+
3+
<p>A <strong>valid</strong> square is a square centered at the origin <code>(0, 0)</code>, has edges parallel to the axes, and <strong>does not</strong> contain two points with the same tag.</p>
4+
5+
<p>Return the <strong>maximum</strong> number of points contained in a <strong>valid</strong> square.</p>
6+
7+
<p>Note:</p>
8+
9+
<ul>
10+
<li>A point is considered to be inside the square if it lies on or within the square&#39;s boundaries.</li>
11+
<li>The side length of the square can be zero.</li>
12+
</ul>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/03/29/3708-tc1.png" style="width: 303px; height: 303px;" /></p>
18+
19+
<div class="example-block">
20+
<p><strong>Input:</strong> <span class="example-io">points = [[2,2],[-1,-2],[-4,4],[-3,1],[3,-3]], s = &quot;abdca&quot;</span></p>
21+
22+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
23+
24+
<p><strong>Explanation:</strong></p>
25+
26+
<p>The square of side length 4 covers two points <code>points[0]</code> and <code>points[1]</code>.</p>
27+
</div>
28+
29+
<p><strong class="example">Example 2:</strong></p>
30+
31+
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/03/29/3708-tc2.png" style="width: 302px; height: 302px;" /></p>
32+
33+
<div class="example-block">
34+
<p><strong>Input:</strong> <span class="example-io">points = [[1,1],[-2,-2],[-2,2]], s = &quot;abb&quot;</span></p>
35+
36+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
37+
38+
<p><strong>Explanation:</strong></p>
39+
40+
<p>The square of side length 2 covers one point, which is <code>points[0]</code>.</p>
41+
</div>
42+
43+
<p><strong class="example">Example 3:</strong></p>
44+
45+
<div class="example-block">
46+
<p><strong>Input:</strong> <span class="example-io">points = [[1,1],[-1,-1],[2,-2]], s = &quot;ccd&quot;</span></p>
47+
48+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
49+
50+
<p><strong>Explanation:</strong></p>
51+
52+
<p>It&#39;s impossible to make any valid squares centered at the origin such that it covers only one point among <code>points[0]</code> and <code>points[1]</code>.</p>
53+
</div>
54+
55+
<p>&nbsp;</p>
56+
<p><strong>Constraints:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= s.length, points.length &lt;= 10<sup>5</sup></code></li>
60+
<li><code>points[i].length == 2</code></li>
61+
<li><code>-10<sup>9</sup> &lt;= points[i][0], points[i][1] &lt;= 10<sup>9</sup></code></li>
62+
<li><code>s.length == points.length</code></li>
63+
<li><code>points</code> consists of distinct coordinates.</li>
64+
<li><code>s</code> consists only of lowercase English letters.</li>
65+
</ul>

0 commit comments

Comments
 (0)