---
# System prepended metadata

title: \#521 Longest Uncommon Subsequence I
tags: [leetcode, leetcode-easy]

---

# \#521 Longest Uncommon Subsequence I
## *給定a,b兩字串, 回傳a,b中最長的"Uncommon Subsequence"長度*
*[Uncommon Subsequence]是指某字串s1在另一個字串s2中, s2去掉某些字元之後可以獲得和s1相同的字串使得sub(s2)=s1, 則此時會稱s1是s2的Uncommon Subsequence(p.s.在這題此定義並不重要)*
## Log
 - build 20211009 by syhuang

## 解答
 - 給定的a,b兩字串本身就是[Uncommon Subsequence], 因此不用去在意它的定義, 只要a!=b, 就回傳較長的字串長度; a==b就沒有所謂"最長", 回傳-1
 - leetcode submit runtime 68%, memory 37%
```javascript=
var findLUSlength = function(a, b) {
    return (a===b)?-1:Math.max(a.length,b.length);
};
```
## 備註
## 參考
- [
I feel this problem is just perfect for April Fools' day](https://leetcode.com/problems/longest-uncommon-subsequence-i/discuss/99410/I-feel-this-problem-is-just-perfect-for-April-Fools'-day)
###### tags: `leetcode`, `leetcode-easy`