Company: Trilogy
Difficulty: medium
Codewriting A cryptarithm is a mathematical puzzle where the goal is to find the correspondence between letters and digits such that the given arithmetic equation consisting of letters holds true. Given a cryptarithm as an array of strings crypt , count the number of its valid solutions. The solution is valid if each letter represents a different digit, and the leading digit of any multi-digit number is not zero. crypt has the following structure: [word1, word2, word3] , which stands for the word1 + word2 = word3 cryptarithm. Input Array of three non-empty strings containing only uppercase English letters. array.string crypt Output integer The number of valid solutions. Constraints 1 ≤ crypt[i].length ≤ 35 Execution time limit: 0.5 seconds (cpp) Memory limit: 1 GB Examples Example 1: crypt = [\"SEND\", \"MORE\", \"MONEY\"] solution(crypt) = 1 Because there is only one solution to this cryptarithm: O = 0, M = 1, Y = 2, E = 5, N = 6, D = 7, R = 8, and S = 9 (9567 + 1085 = 10652) Example