Skip to content

Commit 8b7f828

Browse files
Create README - LeetHub
1 parent cefc3bb commit 8b7f828

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

1656-count-good-triplets/README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/count-good-triplets">1656. Count Good Triplets</a></h2><h3>Easy</h3><hr><p>Given an array of integers <code>arr</code>, and three integers&nbsp;<code>a</code>,&nbsp;<code>b</code>&nbsp;and&nbsp;<code>c</code>. You need to find the number of good triplets.</p>
2+
3+
<p>A triplet <code>(arr[i], arr[j], arr[k])</code>&nbsp;is <strong>good</strong> if the following conditions are true:</p>
4+
5+
<ul>
6+
<li><code>0 &lt;= i &lt; j &lt; k &lt;&nbsp;arr.length</code></li>
7+
<li><code>|arr[i] - arr[j]| &lt;= a</code></li>
8+
<li><code>|arr[j] - arr[k]| &lt;= b</code></li>
9+
<li><code>|arr[i] - arr[k]| &lt;= c</code></li>
10+
</ul>
11+
12+
<p>Where <code>|x|</code> denotes the absolute value of <code>x</code>.</p>
13+
14+
<p>Return<em> the number of good triplets</em>.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong class="example">Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3
21+
<strong>Output:</strong> 4
22+
<strong>Explanation:</strong>&nbsp;There are 4 good triplets: [(3,0,1), (3,0,1), (3,1,1), (0,1,1)].
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong> arr = [1,1,2,2,3], a = 0, b = 0, c = 1
29+
<strong>Output:</strong> 0
30+
<strong>Explanation: </strong>No triplet satisfies all conditions.
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li><code>3 &lt;= arr.length &lt;= 100</code></li>
38+
<li><code>0 &lt;= arr[i] &lt;= 1000</code></li>
39+
<li><code>0 &lt;= a, b, c &lt;= 1000</code></li>
40+
</ul>

0 commit comments

Comments
 (0)