Company: Trilogy Innovations Sde intern Oncampus_17july

Difficulty: hard

Problem Statement

A cryptarithm is a mathematical puzzle in which the goal is to find a correspondence between letters and digits such that a given arithmetic equation written with letters holds true. You are given a cryptarithm as three words word1 , word2 , word3 , standing for the equation word1 + word2 = word3 Count the number of its valid solutions . A solution is valid if each distinct letter represents a different digit (0–9), and the leading digit of any multi-digit number is not zero. Note. A word of length 1 is a single-digit number, so its letter may be 0. Input Format The program reads from standard input: Line 1: the string word1 Line 2: the string word2 Line 3: the string word3 Each word is non-empty and contains only uppercase English letters. Output Format Print a single integer to standard output: the number of valid solutions, followed by a newline. Print 0 if there are none. Constraints 1 ≤ length of each word ≤ 35 Every character is an uppercase English letter ( A –

More Trilogy Innovations Sde intern Oncampus_17july OA questionsInterview experiences