leetcode笔记--7 Find the Difference

question:

Given two strings s and t which consist of only lowercase letters.

String t is generated by random shuffling string s and then add one more letter at a random position.

Find the letter that was added in t.

my answer:

代码看起来有些长,目前还没有想到更好的办法

思路:

将两个字符串分别变成list, 再将list一个个的遍历,获得每个字母对应的个数的字典,再比较两个字典之间的差异。

出错点:

在比较两个字典之间的差异时,是两个条件,一开始忽略了i not in s 这个条件

原文地址:https://www.cnblogs.com/qicaide/p/5920225.html