class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def f(word):
res = 0
for i in word:
res *= 10
res += ord(i) - ord('a')
return res
return f(firstWord) + f(secondWord) == f(targetWord)
leetcode 1880. 检查某单词是否等于两单词之和
最新推荐文章于 2023-07-03 07:33:05 发布