Skip to content
LC-0521 Easy LeetCode

521. Longest Uncommon Subsequence I

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 61% Topics: String
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(min(a, b))
# Space: O(1)

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

Solution from kamyu104/LeetCode-Solutions · MIT