521. Longest Uncommon Subsequenc

作者: fred_33c7 | 来源:发表于2018-07-19 10:48 被阅读0次

题目地址:https://leetcode.com/problems/longest-uncommon-subsequence-i/description/

大意:返回两个字符串的最大非共同序列的字符数字。

思路:这道题目的题干非常长,感觉是为了混淆视听的。。有点想脑经急转弯。如果a和b不想等的话,最大非共同序列不就是长一点的那个序列么。当然,如果两个序列一样,那就返回-1


题目的评论

由于题目太饶人,其实很简单。。很多人都给了。。哈哈哈哈,手动滑稽

class Solution:
    def findLUSlength(self, a, b):
        """
        :type a: str
        :type b: str
        :rtype: int
        """
        return -1 if a == b else max(len(a),len(b))

相关文章

网友评论

    本文标题:521. Longest Uncommon Subsequenc

    本文链接:https://www.haomeiwen.com/subject/cegzpftx.html