0822. Card Flipping Game
https://leetcode.com/problems/card-flipping-game
Description
You are given n
cards, with a positive integer printed on the front and back of each card (possibly different). You can flip any number of cards (possibly zero).
After choosing the front and the back of each card, you will pick each card, and if the integer printed on the back of this card is not printed on the front of any other card, then this integer is good.
You are given two integer array fronts
and backs
where fronts[i]
and backs[i]
are the integers printer on the front and the back of the ith
card respectively.
Return the smallest good and integer after flipping the cards. If there are no good integers, return 0
.
Note that a flip swaps the front and back numbers, so the value on the front is now on the back and vice versa.
Example 1:
Example 2:
Constraints:
n == fronts.length
n == backs.length
1 <= n <= 1000
1 <= fronts[i], backs[i] <= 2000
ac
Last updated