LeetCode Algorithm 389. 找不同

Posted Alex_996

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode Algorithm 389. 找不同相关的知识,希望对你有一定的参考价值。

389. 找不同

Ideas

emmm,排个序,然后挨个比较?

Code

Python

class Solution:
    def findTheDifference(self, s: str, t: str) -> str:
        s = sorted(s)
        t = sorted(t)
        for i, v in enumerate(s):
            if t[i] != v:
                return t[i]
        return t[-1]

以上是关于LeetCode Algorithm 389. 找不同的主要内容,如果未能解决你的问题,请参考以下文章