You are given an array cards where each card is represented by a 2-letter lowercase string.
You are also given a character x.
In the game:
Start with 0 points.
Each card is usable only if it contains the letter x.
You may form a pair from two compatible cards.
Two cards are compatible if they differ in only one of their two positions.
When you form a valid pair, remove both cards and gain 1 point.
The game ends when no more valid compatible pairs exist.
Your task is to determine the maximum number of points possible.
Input: cards = ["ax", "bx", "ay", "by"], x = "x"
Output: 1
Explanation:
The only usable cards based on x: "ax", "bx" They differ by exactly one character → 1 point.
Input: cards = ["ab", "ac", "cb", "cc"], x = "c"
Output: 1
Explanation:
Cards containing 'c' are "ac", "cb", "cc" Possible compatible pair: "cb" & "cc"
Input: cards = ["az", "bz", "cz", "dz"], x = "y"
Output: 0
Explanation:
No card contains the letter 'y', so no scoring is possible.
Accepted:
Submission: