Skip to content

Commit b362f75

Browse files
committed
Create README - LeetHub
1 parent 7607abc commit b362f75

File tree

1 file changed

+31
-0
lines changed
  • 2965-find-missing-and-repeated-values

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<h2><a href="https://leetcode.com/problems/find-missing-and-repeated-values/">2965. Find Missing and Repeated Values</a></h2><h3>Easy</h3><hr><p>You are given a <strong>0-indexed</strong> 2D integer matrix <code><font face="monospace">grid</font></code> of size <code>n * n</code> with values in the range <code>[1, n<sup>2</sup>]</code>. Each integer appears <strong>exactly once</strong> except <code>a</code> which appears <strong>twice</strong> and <code>b</code> which is <strong>missing</strong>. The task is to find the repeating and missing numbers <code>a</code> and <code>b</code>.</p>
2+
3+
<p>Return <em>a <strong>0-indexed </strong>integer array </em><code>ans</code><em> of size </em><code>2</code><em> where </em><code>ans[0]</code><em> equals to </em><code>a</code><em> and </em><code>ans[1]</code><em> equals to </em><code>b</code><em>.</em></p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> grid = [[1,3],[2,2]]
10+
<strong>Output:</strong> [2,4]
11+
<strong>Explanation:</strong> Number 2 is repeated and number 4 is missing so the answer is [2,4].
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> grid = [[9,1,7],[8,9,2],[3,4,6]]
18+
<strong>Output:</strong> [9,5]
19+
<strong>Explanation:</strong> Number 9 is repeated and number 5 is missing so the answer is [9,5].
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>2 &lt;= n == grid.length == grid[i].length &lt;= 50</code></li>
27+
<li><code>1 &lt;= grid[i][j] &lt;= n * n</code></li>
28+
<li>For all <code>x</code> that <code>1 &lt;= x &lt;= n * n</code> there is exactly one <code>x</code> that is not equal to any of the grid members.</li>
29+
<li>For all <code>x</code> that <code>1 &lt;= x &lt;= n * n</code> there is exactly one <code>x</code> that is equal to exactly two of the grid members.</li>
30+
<li>For all <code>x</code> that <code>1 &lt;= x &lt;= n * n</code> except two of them there is exatly one pair of <code>i, j</code> that <code>0 &lt;= i, j &lt;= n - 1</code> and <code>grid[i][j] == x</code>.</li>
31+
</ul>

0 commit comments

Comments
 (0)