1. Description
Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequnece does not exist, return -1.
An uncommon subsequence between two strings is a string that is subsequence of one but not the other.
A subsequence of a string s is a string that can be obtained after deleting any number of characters from s. For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include " aebdc", "aeb", and "" (empty string).
constraints :
- 1 <= a.length, b.length <= 100
- a and b consist of lower-case English letters.
2. Algorithms
- Start
- Return -1 if a is same with b.
- Return max length between a and b.
- End
I can't understand examples of this problem how algorithm get the output.
3. Codes
class Solution:
def findLUSlength(self, a: str, b: str) -> int:
if a == b : return -1
return max(len(a), len(b))
4. Conclusion
'LeetCode > Easy' 카테고리의 다른 글
541 Reverse String II (0) | 2022.09.05 |
---|---|
530 Minimum Absolute Difference in BST (0) | 2022.09.05 |
520 Detect Capital (0) | 2022.09.03 |
511 Game Play Analysis I (0) | 2022.09.03 |
509 Fibonacci Number (0) | 2022.09.03 |