#522
Longest Uncommon Subsequence II
expert · 1020 · lc medium +32 · verified · 44.5% accepted · 555 likes · top 27%
Description
Given an array of strings strs, return the length of the longest string that is a subsequence of exactly one string in the array but not a subsequence of any other. Return -1 if no such string exists.
A subsequence of a string s is formed by deleting zero or more characters without reordering the rest.
- For instance, "abc" is a subsequence of "aebdc" (remove 'e' and 'd').
Example 1:
Input: strs = ["aba","cdc","eae"]
Output: 3
Example 2:
Input: strs = ["aaa","aaa","aa"]
Output: -1
Code
1
2
3