[String-easy] 521. Longest Uncommon Subsequence I nonpublic longest substring

1. The title site

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

2. Title Description

Here Insert Picture Description

3. subject to the effect

Two strings to said longest common subsequence refers to a sequence wherein a sequence rather than a string of another string.

4. Problem-solving ideas

If the two characters are identical, it returns -1 if not identical, a large string length string that is returned to

5. AC Code

class Solution {
    public int findLUSlength(String a, String b) {
         return a.equals(b) ? -1 : Math.max(a.length() , b.length());
    }
}

6. similar questions

[1] 522. Longest Uncommon Subsequence II site topic: https://leetcode.com/problems/longest-uncommon-subsequence-ii/

Guess you like

Origin blog.csdn.net/xiaojie_570/article/details/92767618