Given two strings, you need to find the longest special sequence from the two strings. The longest special sequence is defined as follows: the sequence is the longest subsequence unique to a string (that is, it cannot be a subsequence of other strings).
Subsequences can be achieved by removing certain characters from the string, but cannot change the relative order of the remaining characters. An empty sequence is a subsequence of all strings, and any string is a subsequence of itself.
The input is two strings, and the output is the length of the longest special sequence. Returns -1 if not present.
Example:
Input: "aba", "cdc"
Output: 3
Analysis: The longest special sequence can be "aba" (or "cdc")
Explanation:
1. Both strings are less than 100 in length.
2. The characters in the string only contain 'a'~'z'.
See: https://leetcode.com/problems/longest-uncommon-subsequence-i/description/
C++:
class Solution { public: int findLUSlength(string a, string b) { return a==b?-1:max(a.size(),b.size()); } };