Skip to content

Practice Subsequence With the Minimum Score

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

Hard#2565
LeetCode Problem

Subsequence With the Minimum Score

Problem Statement

Delete characters from t until the remaining string is a subsequence of s. The score is 0 if none are removed; otherwise it is right - left + 1 using the largest and smallest original indices of removed characters. Return the minimum possible score, rather than the number of deletions.

Source: Subsequence With the Minimum Score on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "abacaba", t = "bzaa"
Output
1

# Example 2

Input
s = "cde", t = "xyz"
Output
3

Constraints

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

Related LeetCode Problems

Practice more problems similar to Subsequence With the Minimum Score.

Review your practice with PhantomCodeAI

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