Leetcode 389. Find the Difference

多了一个字母,就两个字符串一减就得到多的那个.

但是字符串不能直接相减,所以就转成数字再减,最后再转回来.

class Solution(object):
    def findTheDifference(self, s, t):
        return chr(sum(map(ord,t))-sum(map(ord,s)))

猜你喜欢

转载自www.cnblogs.com/zywscq/p/10659522.html