Company: Trilogy_27july
Difficulty: medium
Cryptarithm Problem Description A cryptarithm is a letter-substitution puzzle: you must map each distinct letter to a digit so that the resulting arithmetic statement, written using those letters, is numerically correct. Given a cryptarithm represented as an array of strings crypt , count how many valid digit assignments satisfy it. An assignment is valid when every letter maps to its own distinct digit (0-9) and no multi-digit number in the puzzle begins with a zero. The crypt array always has the shape [word1, word2, word3] , representing the equation word1 + word2 == word3 . You need to implement the following function: int solution(String[] crypt) Examples Example 1: Input: crypt = ["SEND", "MORE", "MONEY"] Output: 1 Explanation: There is only one solution to this cryptarithm: S=9, E=5, N=6, D=7, M=1, O=0, R=8, Y=2 . This maps to 9567 + 1085 = 10652 . Example 2: Input: crypt = ["GREEN", "BLUE", "BLACK"] Output: 12 Explanation: There are 12 possible valid solutions. For example, one