Sequence Check

Prereq: Knapsack Intro

Given 2 strings determine how many distinct subsequences of s equal t. A subsequence of s is a the original sequence s with some characters deleted. The answer is guaranteed to be less than 2^31-1.

Constraints

1 <= s.length, t.length <= 100001

The strings s and t will only contain lowercase english letters

Examples

Example 1

Input: s = "rabbbit", t = "rabbit"
Output: 3
Explanation:

You can remove any of the 3 middle b values from s to make the t value

Try it Yourself

Title

Script

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

  >>> a = [1, 2, 3]
  >>> a[-1]
  3

Get premium for instant access to all content and solutions

Upgrade