​https://leetcode-cn.com/problems/longest-uncommon-subsequence-i/​

521. 最长特殊序列 Ⅰ_leetcode

思路:
分条件判断
1,当a和b一样时,返回-1
2,当a的长度和b的长度一样但不相等时,则根据示例可知,a、b都是最长特殊序列
因为都是独有的的
3,当a和b长度不一样时,返回最长的即可,因为当a的长度大于b时,b中必定没有a长度的序列

class Solution {
//当a和b相等时,返回-1
public int findLUSlength(String a, String b) {
if(a.equals(b))
return -1;
return Math.max(a.length(),b.length());
}

}