Skip to content

Commit cec7184

Browse files
committed
Create README - LeetHub
1 parent 9f1b4a9 commit cec7184

File tree

1 file changed

+49
-0
lines changed
  • check-array-formation-through-concatenation

1 file changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<h2>1640. Check Array Formation Through Concatenation</h2><h3>Easy</h3><hr><div><p>You are given an array of <strong>distinct</strong> integers <code>arr</code> and an array of integer arrays <code>pieces</code>, where the integers in <code>pieces</code> are <strong>distinct</strong>. Your goal is to form <code>arr</code> by concatenating the arrays in <code>pieces</code> <strong>in any order</strong>. However, you are <strong>not</strong> allowed to reorder the integers in each array <code>pieces[i]</code>.</p>
2+
3+
<p>Return <code>true</code> <em>if it is possible </em><em>to form the array </em><code>arr</code><em> from </em><code>pieces</code>. Otherwise, return <code>false</code>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong>Example 1:</strong></p>
7+
8+
<pre><strong>Input:</strong> arr = [85], pieces = [[85]]
9+
<strong>Output:</strong> true
10+
</pre>
11+
12+
<p><strong>Example 2:</strong></p>
13+
14+
<pre><strong>Input:</strong> arr = [15,88], pieces = [[88],[15]]
15+
<strong>Output:</strong> true
16+
<strong>Explanation:</strong> Concatenate <code>[15]</code> then <code>[88]</code>
17+
</pre>
18+
19+
<p><strong>Example 3:</strong></p>
20+
21+
<pre><strong>Input:</strong> arr = [49,18,16], pieces = [[16,18,49]]
22+
<strong>Output:</strong> false
23+
<strong>Explanation:</strong> Even though the numbers match, we cannot reorder pieces[0].
24+
</pre>
25+
26+
<p><strong>Example 4:</strong></p>
27+
28+
<pre><strong>Input:</strong> arr = [91,4,64,78], pieces = [[78],[4,64],[91]]
29+
<strong>Output:</strong> true
30+
<strong>Explanation:</strong> Concatenate <code>[91]</code> then <code>[4,64]</code> then <code>[78]</code></pre>
31+
32+
<p><strong>Example 5:</strong></p>
33+
34+
<pre><strong>Input:</strong> arr = [1,3,5,7], pieces = [[2,4,6,8]]
35+
<strong>Output:</strong> false
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= pieces.length &lt;= arr.length &lt;= 100</code></li>
43+
<li><code>sum(pieces[i].length) == arr.length</code></li>
44+
<li><code>1 &lt;= pieces[i].length &lt;= arr.length</code></li>
45+
<li><code>1 &lt;= arr[i], pieces[i][j] &lt;= 100</code></li>
46+
<li>The integers in&nbsp;<code>arr</code>&nbsp;are <strong>distinct</strong>.</li>
47+
<li>The integers in&nbsp;<code>pieces</code> are <strong>distinct</strong>&nbsp;(i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).</li>
48+
</ul>
49+
</div>

0 commit comments

Comments
 (0)