Skip to content

Commit dc155b5

Browse files
committed
2260. Minimum Consecutive Cards to Pick Up: RETRY
1 parent 49b9939 commit dc155b5

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/solution/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,3 +1710,4 @@ mod s2256_minimum_average_difference;
17101710
mod s2257_count_unguarded_cells_in_the_grid;
17111711
mod s2258_escape_the_spreading_fire;
17121712
mod s2259_remove_digit_from_number_to_maximize_result;
1713+
mod s2260_minimum_consecutive_cards_to_pick_up;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* [2260] Minimum Consecutive Cards to Pick Up
3+
*
4+
* You are given an integer array cards where cards[i] represents the value of the i^th card. A pair of cards are matching if the cards have the same value.
5+
* 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.
6+
*
7+
* Example 1:
8+
*
9+
* Input: cards = [3,4,2,3,4,7]
10+
* Output: 4
11+
* Explanation: 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+
*
13+
* Example 2:
14+
*
15+
* Input: cards = [1,0,5,3]
16+
* Output: -1
17+
* Explanation: There is no way to pick up a set of consecutive cards that contain a pair of matching cards.
18+
*
19+
*
20+
* Constraints:
21+
*
22+
* 1 <= cards.length <= 10^5
23+
* 0 <= cards[i] <= 10^6
24+
*
25+
*/
26+
pub struct Solution {}
27+
28+
// problem: https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up/
29+
// discuss: https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up/discuss/?currentPage=1&orderBy=most_votes&query=
30+
31+
// submission codes start here
32+
33+
impl Solution {
34+
pub fn minimum_card_pickup(cards: Vec<i32>) -> i32 {
35+
0
36+
}
37+
}
38+
39+
// submission codes end
40+
41+
#[cfg(test)]
42+
mod tests {
43+
use super::*;
44+
45+
#[test]
46+
#[ignore]
47+
fn test_2260_example_1() {
48+
let cards = vec![3, 4, 2, 3, 4, 7];
49+
50+
let result = 4;
51+
52+
assert_eq!(Solution::minimum_card_pickup(cards), result);
53+
}
54+
55+
#[test]
56+
#[ignore]
57+
fn test_2260_example_2() {
58+
let cards = vec![1, 0, 5, 3];
59+
60+
let result = -1;
61+
62+
assert_eq!(Solution::minimum_card_pickup(cards), result);
63+
}
64+
}

0 commit comments

Comments
 (0)