Skip to content

Commit 88b6b43

Browse files
committed
Create README - LeetHub
1 parent 93594c5 commit 88b6b43

File tree

1 file changed

+34
-0
lines changed
  • 3685-count-subarrays-of-length-three-with-a-condition

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<h2><a href="https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition">3685. Count Subarrays of Length Three With a Condition</a></h2><h3>Easy</h3><hr><p>Given an integer array <code>nums</code>, return the number of <span data-keyword="subarray-nonempty">subarrays</span> of length 3 such that the sum of the first and third numbers equals <em>exactly</em> half of the second number.</p>
2+
3+
<p>&nbsp;</p>
4+
<p><strong class="example">Example 1:</strong></p>
5+
6+
<div class="example-block">
7+
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,1,4,1]</span></p>
8+
9+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
10+
11+
<p><strong>Explanation:</strong></p>
12+
13+
<p>Only the subarray <code>[1,4,1]</code> contains exactly 3 elements where the sum of the first and third numbers equals half the middle number.</p>
14+
</div>
15+
16+
<p><strong class="example">Example 2:</strong></p>
17+
18+
<div class="example-block">
19+
<p><strong>Input:</strong> <span class="example-io">nums = [1,1,1]</span></p>
20+
21+
<p><strong>Output:</strong> <span class="example-io">0</span></p>
22+
23+
<p><strong>Explanation:</strong></p>
24+
25+
<p><code>[1,1,1]</code> is the only subarray of length 3. However, its first and third numbers do not add to half the middle number.</p>
26+
</div>
27+
28+
<p>&nbsp;</p>
29+
<p><strong>Constraints:</strong></p>
30+
31+
<ul>
32+
<li><code>3 &lt;= nums.length &lt;= 100</code></li>
33+
<li><code><font face="monospace">-100 &lt;= nums[i] &lt;= 100</font></code></li>
34+
</ul>

0 commit comments

Comments
 (0)