1307. Verbal Arithmetic Puzzle
https://leetcode.com/problems/verbal-arithmetic-puzzle
Description
Given an equation, represented by words
on left side and the result
on right side.
You need to check if the equation is solvable under the following rules:
Each character is decoded as one digit (0 - 9).
Every pair of different characters they must map to different digits.
Each
words[i]
andresult
are decoded as one number without leading zeros.Sum of numbers on left side (
words
) will equal to the number on right side (result
).
Return True
if the equation is solvable otherwise return False
.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
2 <= words.length <= 5
1 <= words[i].length, result.length <= 7
words[i], result
contain only uppercase English letters.The number of different characters used in the expression is at most
10
.
ac
Last updated