Skip to content

Commit 18efcca

Browse files
committed
Create README - LeetHub
1 parent 605327d commit 18efcca

File tree

1 file changed

+41
-0
lines changed
  • 1497-check-if-array-pairs-are-divisible-by-k

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<h2><a href="https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k">1497. Check If Array Pairs Are Divisible by k</a></h2><h3>Medium</h3><hr><p>Given an array of integers <code>arr</code> of even length <code>n</code> and an integer <code>k</code>.</p>
2+
3+
<p>We want to divide the array into exactly <code>n / 2</code> pairs such that the sum of each pair is divisible by <code>k</code>.</p>
4+
5+
<p>Return <code>true</code><em> If you can find a way to do that or </em><code>false</code><em> otherwise</em>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> arr = [1,2,3,4,5,10,6,7,8,9], k = 5
12+
<strong>Output:</strong> true
13+
<strong>Explanation:</strong> Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).
14+
</pre>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<pre>
19+
<strong>Input:</strong> arr = [1,2,3,4,5,6], k = 7
20+
<strong>Output:</strong> true
21+
<strong>Explanation:</strong> Pairs are (1,6),(2,5) and(3,4).
22+
</pre>
23+
24+
<p><strong class="example">Example 3:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> arr = [1,2,3,4,5,6], k = 10
28+
<strong>Output:</strong> false
29+
<strong>Explanation:</strong> You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.
30+
</pre>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Constraints:</strong></p>
34+
35+
<ul>
36+
<li><code>arr.length == n</code></li>
37+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
38+
<li><code>n</code> is even.</li>
39+
<li><code>-10<sup>9</sup> &lt;= arr[i] &lt;= 10<sup>9</sup></code></li>
40+
<li><code>1 &lt;= k &lt;= 10<sup>5</sup></code></li>
41+
</ul>

0 commit comments

Comments
 (0)