522. Longest Uncommon Subsequence II Medium

@problem@discussion
#Array#Hash Table#Two Pointers#String#Sorting



1/**
2 * [522] Longest Uncommon Subsequence II
3 *
4 * Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1.
5 * An uncommon subsequence between an array of strings is a string that is a subsequence of one string but not the others.
6 * A subsequence of a string s is a string that can be obtained after deleting any number of characters from s.
7 * 
8 * 	For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "a<u>e</u>b<u>d</u>c" to get "abc". Other subsequences of "aebdc" include "aebdc", "aeb", and "" (empty string).
9 * 
10 *  
11 * Example 1:
12 * Input: strs = ["aba","cdc","eae"]
13 * Output: 3
14 * Example 2:
15 * Input: strs = ["aaa","aaa","aa"]
16 * Output: -1
17 *  
18 * Constraints:
19 * 
20 * 	2 <= strs.length <= 50
21 * 	1 <= strs[i].length <= 10
22 * 	strs[i] consists of lowercase English letters.
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/longest-uncommon-subsequence-ii/
28// discuss: https://leetcode.com/problems/longest-uncommon-subsequence-ii/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn find_lu_slength(strs: Vec<String>) -> i32 {
34        0
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_522() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.