- Leetcode PHP题解--D73 389. Find th
- LeetCode 389 [Find the Differenc
- Leetcode 389. Find the Differenc
- LeetCode 389. Find the Differenc
- 每日一题20201218(389. 找不同)
- [LeetCode][Python]389. Find the
- [LeetCode]389. Find the Differen
- [刷题防痴呆] 0539 - 最小时间差 (Minimum Ti
- [LeetCode By Go 25]389. Find the
- LeetCode #1026 Maximum Differenc
原题
给出两个字符串,只有一处不同,一个字符串比两一个多一个字符,找出这个字符
样例
Input:
s = "abcd"
t = "abcde"
Output:
e
Explanation:
'e' is the letter that was added.
解题思路
- 合并两个字符串,题目转化为寻找单身狗
完整代码
class Solution(object):
def findTheDifference(self, s, t):
"""
:type s: str
:type t: str
:rtype: str
"""
temp = 0
for char in s + t:
temp = temp ^ ord(char)
return chr(temp)
网友评论