Practice Minimum Consecutive Cards to Pick Up
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same value. Return the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching cards, return -1.
Source: Minimum Consecutive Cards to Pick Up on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
cards = [3,4,2,3,4,7]
4
# Example 2
cards = [1,0,5,3]
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Consecutive Cards to Pick Up.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.