The Wording Game - Problem
The Wording Game is an exciting two-player word competition between Alice and Bob! ๐ŸŽฎ

Each player has their own lexicographically sorted array of words. The game follows these strategic rules:

๐ŸŽฏ Goal: Be the last player able to make a valid move
๐Ÿ“ Rules:
โ€ข Players alternate turns, with Alice starting first using her lexicographically smallest word
โ€ข Each subsequent word must be "closely greater" than the previous word
โ€ข The first player unable to make a valid move loses

๐Ÿ” "Closely Greater" Definition:
A word w is closely greater than word z if:
1. w is lexicographically greater than z
2. The first letter of w is either the same as the first letter of z, OR the next letter in the alphabet

Example: "care" is closely greater than "book" (c comes after b) and "car" (same first letter, lexicographically greater), but NOT closely greater than "ant" (c is not immediately after a) or "cook" (care < cook lexicographically).

Given both players play optimally, determine if Alice can guarantee a win!

Input & Output

Constraints

Asked in
25.0K Views
Medium Frequency
~15 min Avg. Time
850 Likes
Ln 1, Col 1
Smart Actions
๐Ÿ’ก Explanation
AI Ready
๐Ÿ’ก Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen