Company: Codenation_23june
Difficulty: medium
Cryptarithm Problem Description A cryptarithm is a letter-substitution puzzle: you must assign a digit to every distinct letter so that the resulting arithmetic sum checks out. You are given a cryptarithm as an array of strings crypt . Determine how many distinct digit assignments make it valid. An assignment counts as valid only when every letter maps to a different digit and no multi-digit number begins with a zero digit. crypt always has the shape [word1, word2, word3] , representing the equation word1 + word2 = word3 . Examples Example 1: Input: crypt = ["SEND", "MORE", "MONEY"] Output: 1 Explanation: Only one letter-to-digit mapping satisfies the equation: O = 0, M = 1, Y = 2, E = 5, N = 6, D = 7, R = 8, and S = 9 (9567 + 1085 = 10652). Example 2: Input: crypt = ["GREEN", "BLUE", "BLACK"] Output: 12 Explanation: Twelve different mappings satisfy the equation: 54889 + 6138 = 61027 18559 + 2075 = 20634 72449 + 8064 = 80513 48229 + 5372 = 53601 47119 + 5261 = 52380 36887 + 4028 = 409