class Solution:
def findTheDifference(self, s, t):
"""
:type s: str
:type t: str
:rtype: str
"""
"""
T = []
for i in t:
T.append(i)
for j in s:
T.remove(j)
return T[0]
"""
for i in range(len(t)):
if t.count(t[i]) != s.count(t[i]):
return t[i]
分别对同一字符计数,不同则返回
本文介绍了一种算法,用于找出两个字符串中不同的字符。通过对比字符频率,可以高效地找到唯一出现在第二个字符串中的字符。
274

被折叠的 条评论
为什么被折叠?



