Tap here to switch tabs
Problem
Submissions

Problem: Two-Letter Card Game

Two-Letter Card Game asks you to remove the maximum number of pairs from a card array, matching cards that share x in the same position while differing in the other.

Statement

You are given an array of two character strings cards and a character x.

In one turn, you can select and remove two compatible cards from cards. Two cards are considered compatible if:

  • Both cards contain the character x at the same index, either both at index 00 or both at index 11.

  • The characters at the other index are different.

Return the maximum number of turns you can make.

Constraints:

  • 2≤2 \leq cards.length ≤105\leq 10^5

  • cards[i].length =2= 2

  • Each cards[i] is composed of only lowercase English letters between 'a' and 'j'

  • x is a lowercase English letter between 'a' and 'j'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Two-Letter Card Game

Two-Letter Card Game asks you to remove the maximum number of pairs from a card array, matching cards that share x in the same position while differing in the other.

Statement

You are given an array of two character strings cards and a character x.

In one turn, you can select and remove two compatible cards from cards. Two cards are considered compatible if:

  • Both cards contain the character x at the same index, either both at index 00 or both at index 11.

  • The characters at the other index are different.

Return the maximum number of turns you can make.

Constraints:

  • 2≤2 \leq cards.length ≤105\leq 10^5

  • cards[i].length =2= 2

  • Each cards[i] is composed of only lowercase English letters between 'a' and 'j'

  • x is a lowercase English letter between 'a' and 'j'