Skip to content

Practice Append Characters to String to Make Subsequence

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

Medium#2486
LeetCode Problem

Append Characters to String to Make Subsequence

Problem Statement

You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s. A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

Source: Append Characters to String to Make Subsequence on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "coaching", t = "coding"
Output
4

# Example 2

Input
s = "abcde", t = "a"
Output
0

# Example 3

Input
s = "z", t = "abcde"
Output
5

Constraints

1 <= s.length, t.length <= 10^5
s and t consist only of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Append Characters to String to Make Subsequence.

Review your practice with PhantomCodeAI

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