力扣第389题—找不同
class Solution:def findTheDifference(self, s: str, t: str) -> str:# 对字符串 s 和 t 进行排序a = sorted(s)b = sorted(t)# 比较排序后的两个列表for i in range(len(a)):if a[i] != b[i]:return b[i]# 如果前面的比较没有找到差异,那么差异字符在 t 的最后一个位置return b[-1]
class Solution:def findTheDifference(self, s: str, t: str) -> str:# 对字符串 s 和 t 进行排序a = sorted(s)b = sorted(t)# 比较排序后的两个列表for i in range(len(a)):if a[i] != b[i]:return b[i]# 如果前面的比较没有找到差异,那么差异字符在 t 的最后一个位置return b[-1]