解题思路
我们可以采用ascii之差,求出所添加字符。
代码
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
num_s,num_t = 0,0
for i in s:
num_s += ord(i)
for i in t:
num_t += ord(i)
return chr(num_t - num_s)