Skip to content

Commit 7ee747e

Browse files
committed
Create README - LeetHub
1 parent 4d3ff7a commit 7ee747e

File tree

1 file changed

+62
-0
lines changed
  • 3432-count-partitions-with-even-sum-difference

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<h2><a href="https://leetcode.com/problems/count-partitions-with-even-sum-difference">3704. Count Partitions with Even Sum Difference</a></h2><h3>Easy</h3><hr><p>You are given an integer array <code>nums</code> of length <code>n</code>.</p>
2+
3+
<p>A <strong>partition</strong> is defined as an index <code>i</code> where <code>0 &lt;= i &lt; n - 1</code>, splitting the array into two <strong>non-empty</strong> subarrays such that:</p>
4+
5+
<ul>
6+
<li>Left subarray contains indices <code>[0, i]</code>.</li>
7+
<li>Right subarray contains indices <code>[i + 1, n - 1]</code>.</li>
8+
</ul>
9+
10+
<p>Return the number of <strong>partitions</strong> where the <strong>difference</strong> between the <strong>sum</strong> of the left and right subarrays is <strong>even</strong>.</p>
11+
12+
<p>&nbsp;</p>
13+
<p><strong class="example">Example 1:</strong></p>
14+
15+
<div class="example-block">
16+
<p><strong>Input:</strong> <span class="example-io">nums = [10,10,3,7,6]</span></p>
17+
18+
<p><strong>Output:</strong> <span class="example-io">4</span></p>
19+
20+
<p><strong>Explanation:</strong></p>
21+
22+
<p>The 4 partitions are:</p>
23+
24+
<ul>
25+
<li><code>[10]</code>, <code>[10, 3, 7, 6]</code> with a sum difference of <code>10 - 26 = -16</code>, which is even.</li>
26+
<li><code>[10, 10]</code>, <code>[3, 7, 6]</code> with a sum difference of <code>20 - 16 = 4</code>, which is even.</li>
27+
<li><code>[10, 10, 3]</code>, <code>[7, 6]</code> with a sum difference of <code>23 - 13 = 10</code>, which is even.</li>
28+
<li><code>[10, 10, 3, 7]</code>, <code>[6]</code> with a sum difference of <code>30 - 6 = 24</code>, which is even.</li>
29+
</ul>
30+
</div>
31+
32+
<p><strong class="example">Example 2:</strong></p>
33+
34+
<div class="example-block">
35+
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,2]</span></p>
36+
37+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
38+
39+
<p><strong>Explanation:</strong></p>
40+
41+
<p>No partition results in an even sum difference.</p>
42+
</div>
43+
44+
<p><strong class="example">Example 3:</strong></p>
45+
46+
<div class="example-block">
47+
<p><strong>Input:</strong> <span class="example-io">nums = [2,4,6,8]</span></p>
48+
49+
<p><strong>Output:</strong> <span class="example-io">3</span></p>
50+
51+
<p><strong>Explanation:</strong></p>
52+
53+
<p>All partitions result in an even sum difference.</p>
54+
</div>
55+
56+
<p>&nbsp;</p>
57+
<p><strong>Constraints:</strong></p>
58+
59+
<ul>
60+
<li><code>2 &lt;= n == nums.length &lt;= 100</code></li>
61+
<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
62+
</ul>

0 commit comments

Comments
 (0)