Alice and Bob each have a lexicographically sorted array of strings named a and b respectively. They are playing a wording game with the following rules:
On each turn, the current player should play a word from their list such that the new word is closely greater than the last played word; then it's the other player's turn. If a player can't play a word on their turn, they lose.
Alice starts the game by playing her lexicographically smallest word. Given a and b, return true if Alice can win knowing that both players play their best, and false otherwise.
A word w is closely greater than a word z if the following conditions are met:
wis lexicographically greater thanz- If
w1is the first letter ofwandz1is the first letter ofz,w1should either be equal toz1or be the letter afterz1in the alphabet
For example, the word "care" is closely greater than "book" and "car", but is not closely greater than "ant" or "cook".
Input & Output
Constraints
- 1 ≤ a.length, b.length ≤ 1000
- 1 ≤ a[i].length, b[i].length ≤ 100
- a and b consist of lowercase English letters only
- All strings in a and b are distinct
- Arrays a and b are lexicographically sorted