Skip to content

Practice Longest Uncommon Subsequence I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#521
LeetCode Problem

Longest Uncommon Subsequence I

Problem Statement

Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If no such uncommon subsequence exists, return -1. An uncommon subsequence between two strings is a string that is a subsequence of exactly one of them.

Source: Longest Uncommon Subsequence I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
a = "aba", b = "cdc"
Output
3

# Example 2

Input
a = "aaa", b = "bbb"
Output
3

# Example 3

Input
a = "aaa", b = "aaa"
Output
-1

Constraints

1 <= a.length, b.length <= 100
a and b consist of lower-case English letters.

Related LeetCode Problems

Practice more problems similar to Longest Uncommon Subsequence I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.