You are given an array of strings and need to find the longest uncommon subsequence among them. An uncommon subsequence is a string that is a subsequence of exactly one string in the array, but not a subsequence of any other string.
A subsequence is formed by deleting some (possibly zero) characters from a string while maintaining the relative order of remaining characters. For example, "abc" is a subsequence of "aebdc" by removing characters at positions 1 and 3.
Goal: Return the length of the longest uncommon subsequence. If no uncommon subsequence exists, return -1.
Key Insight: Any string that appears only once in the array is automatically an uncommon subsequence (since it's a subsequence of itself but not of any other string)!
Input & Output
Constraints
- 2 โค strs.length โค 50
- 1 โค strs[i].length โค 10
- strs[i] consists of lowercase English letters only