> For the complete documentation index, see [llms.txt](https://programming.arora-aditya.com/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://programming.arora-aditya.com/leetcode/string/521.-longest-uncommon-subsequence-i.md).

# 521. Longest Uncommon Subsequence I

## Approach 1:  String lengths

If string lengths are unequal we can just return the length of the longer string, since it obviously won't be the substring of the smaller string

Moreover if the string lengths are equal and the strings aren't equal, then either of those lengths will work. Moreover as the question states if the strings are equal then we have to return -1

```python
class Solution(object):
    def findLUSlength(self, a, b):
        """
        https://leetcode.com/problems/longest-uncommon-subsequence-i/description/
        :type a: str
        :type b: str
        :rtype: int
        """
        lea, leb = len(a), len(b)
        if lea != leb:
            return max(lea, leb)
        if a == b:
            return -1
        else:
            return lea
```

> **Time Complexity:** *O(N), \[length and string comparison are O(N)]*
>
> **Space Complexity:** *O(1)*
