1 line Python


  • 0

    Take me a while to think through the problem, even had the doubt whether it is a easy problem at all. Then suddenly I realized when a != b, the longer one can never be the subsequence of the short one. What a joke! Anyway, happy April Fools' day.

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

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.