There are some cards placed in a line. Each card is characterized by the three
distinct letters written on it.
The conformity-level of two cards is the number of distinct letters that are common to both cards.
For example, the conformity-level of "ABC" and "ACD" is 2 because the letters 'A' and 'C' are common to both cards, and the conformity-level of "ABC" and "DFE" is 0 because the two cards share no common letters.
You can remove a card if the conformity-level of its left neighbor and its right neighbor is greater than or equal to 2. Once a card is removed its left and right neighbors become neighbors themselves.
The leftmost and rightmost cards are never removed.
Given a String[] cards, determine the maximum quantity of cards that you can
remove.
|