[LeetCode] #389. Find the Difference
1 min readMar 14, 2020
Environment: Python 3.7
Key technique: “count” and “not in” function
Example:
Input:
s = "abcd"
t = "abcde"Output:
eExplanation:
'e' is the letter that was added.
Analysis:
I get some miss understanding when try to solve it. This problem find added string and does not find the string never showing.
Solution:
class Solution:
def findTheDifference(self, s: str, t: str) -> str:
for i in t:
if(i not in s or s.count(i)!=t.count(i)):
diff=i
return diff
Submitted result:
Reference:
https://leetcode.com/problems/find-the-difference/discuss/472745/Simple-Python-(98-100)