Tap here to switch tabs
Problem
Submissions

Problem: Subsequence With the Minimum Score

med
30 min
Try to solve the Subsequence With the Minimum Score problem.

Statement

You are given two strings, s and t.

You are allowed to remove a contiguous substring from t starting at index left and ending at index right, where 0≤0 \leq left ≤\leq right << t.length. The score of this operation is defined as right −- left +1+ 1. If no substring is removed, the score is 00.

Return the minimum possible score such that the remaining characters of t form a subsequence of s.

Note: A subsequence of a string is a new string formed from the original string by deleting some (can be none) of the characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq s.length, t.length ≤105\leq 10^5

  • s and t consist of only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subsequence With the Minimum Score

med
30 min
Try to solve the Subsequence With the Minimum Score problem.

Statement

You are given two strings, s and t.

You are allowed to remove a contiguous substring from t starting at index left and ending at index right, where 0≤0 \leq left ≤\leq right << t.length. The score of this operation is defined as right −- left +1+ 1. If no substring is removed, the score is 00.

Return the minimum possible score such that the remaining characters of t form a subsequence of s.

Note: A subsequence of a string is a new string formed from the original string by deleting some (can be none) of the characters without changing the relative order of the remaining characters.

Constraints:

  • 1≤1 \leq s.length, t.length ≤105\leq 10^5

  • s and t consist of only lowercase English letters.