822. Card Flipping Game Medium
1/**
2 * [822] Card Flipping Game
3 *
4 * You are given two 0-indexed integer arrays fronts and backs of length n, where the i^th card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may flip over any number of cards (possibly zero).
5 * After flipping the cards, an integer is considered good if it is facing down on some card and not facing up on any card.
6 * Return the minimum possible good integer after flipping the cards. If there are no good integers, return 0.
7 *
8 * Example 1:
9 *
10 * Input: fronts = [1,2,4,4,7], backs = [1,3,4,1,3]
11 * Output: 2
12 * Explanation:
13 * If we flip the second card, the face up numbers are [1,3,4,4,7] and the face down are [1,2,4,1,3].
14 * 2 is the minimum good integer as it appears facing down but not facing up.
15 * It can be shown that 2 is the minimum possible good integer obtainable after flipping some cards.
16 *
17 * Example 2:
18 *
19 * Input: fronts = [1], backs = [1]
20 * Output: 0
21 * Explanation:
22 * There are no good integers no matter how we flip the cards, so we return 0.
23 *
24 *
25 * Constraints:
26 *
27 * n == fronts.length == backs.length
28 * 1 <= n <= 1000
29 * 1 <= fronts[i], backs[i] <= 2000
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/card-flipping-game/
35// discuss: https://leetcode.com/problems/card-flipping-game/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn flipgame(fronts: Vec<i32>, backs: Vec<i32>) -> i32 {
41 0
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_822() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.