The "Verbal Arithmetic Puzzle" interview question is a "Hard" difficulty problem that asks you to solve a cryptarithmetic puzzle. You are given a list of words and a result word. Each unique character in these words must be assigned a unique digit (0-9) such that the sum of the input words equals the result word. Also, no word can have a leading zero if its length is greater than one.
Atlassian and Google use the "Verbal Arithmetic Puzzle" coding problem to test a candidate's proficiency with "Backtracking interview patterns" and pruning techniques. This problem has a massive search space, so simply trying all permutations will fail. It evaluates your ability to optimize recursion and handle constraints effectively.
The core pattern is "Backtracking with Pruning." You map each character to a digit. A smart way to solve this is to work column by column from right to left (the units place, the tens place, etc.), similar to how you perform long addition. This allows you to check if the current sum matches the result's digit at that position immediately, allowing you to "prune" (stop) branches of the recursion early.
Puzzle: ["SEND", "MORE"], Result: "MONEY"
D + E = Y (or Y + 10).D=7, E=5, then 7+5=12, so Y=2 and carry=1.N + R + carry = E.The most common mistake is not pruning the search tree, leading to a TLE (Time Limit Exceeded) error. Another is forgetting the "unique digit" constraint (two different letters cannot represent the same number). Candidates also often struggle with managing the "carry" value between columns in the recursive calls.
For the "Verbal Arithmetic Puzzle" coding problem, pre-calculating the power-of-10 weight for each character can simplify the logic. For example, in "SEND", S has weight 1000, E has 100, N has 10, and D has 1. This allows you to represent the puzzle as a single equation.