Skip to content

Commit 9e9b243

Browse files
committed
Create README - LeetHub
1 parent 911b489 commit 9e9b243

File tree

1 file changed

+28
-0
lines changed
  • 2338-minimum-consecutive-cards-to-pick-up

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up">2338. Minimum Consecutive Cards to Pick Up</a></h2><h3>Medium</h3><hr><p>You are given an integer array <code>cards</code> where <code>cards[i]</code> represents the <strong>value</strong> of the <code>i<sup>th</sup></code> card. A pair of cards are <strong>matching</strong> if the cards have the <strong>same</strong> value.</p>
2+
3+
<p>Return<em> the <strong>minimum</strong> number of <strong>consecutive</strong> cards you have to pick up to have a pair of <strong>matching</strong> cards among the picked cards.</em> If it is impossible to have matching cards, return <code>-1</code>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> cards = [3,4,2,3,4,7]
10+
<strong>Output:</strong> 4
11+
<strong>Explanation:</strong> We can pick up the cards [3,4,2,3] which contain a matching pair of cards with value 3. Note that picking up the cards [4,2,3,4] is also optimal.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> cards = [1,0,5,3]
18+
<strong>Output:</strong> -1
19+
<strong>Explanation:</strong> There is no way to pick up a set of consecutive cards that contain a pair of matching cards.
20+
</pre>
21+
22+
<p>&nbsp;</p>
23+
<p><strong>Constraints:</strong></p>
24+
25+
<ul>
26+
<li><code>1 &lt;= cards.length &lt;= 10<sup>5</sup></code></li>
27+
<li><code>0 &lt;= cards[i] &lt;= 10<sup>6</sup></code></li>
28+
</ul>

0 commit comments

Comments
 (0)