521. Longest Uncommon Subsequence I Easy
1/**
2 * [521] Longest Uncommon Subsequence I
3 *
4 * Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If the longest uncommon subsequence does not exist, return -1.
5 * An uncommon subsequence between two strings is a string that is a subsequence of one but not the other.
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 *
13 * Input: a = "aba", b = "cdc"
14 * Output: 3
15 * Explanation: One longest uncommon subsequence is "aba" because "aba" is a subsequence of "aba" but not "cdc".
16 * Note that "cdc" is also a longest uncommon subsequence.
17 *
18 * Example 2:
19 *
20 * Input: a = "aaa", b = "bbb"
21 * Output: 3
22 * Explanation: The longest uncommon subsequences are "aaa" and "bbb".
23 *
24 * Example 3:
25 *
26 * Input: a = "aaa", b = "aaa"
27 * Output: -1
28 * Explanation: Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a.
29 *
30 *
31 * Constraints:
32 *
33 * 1 <= a.length, b.length <= 100
34 * a and b consist of lower-case English letters.
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/longest-uncommon-subsequence-i/
40// discuss: https://leetcode.com/problems/longest-uncommon-subsequence-i/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn find_lu_slength(a: String, b: String) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_521() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.